# Get the caller's billing overview

`GET /v1/me/billing`

URL: https://docs.spacerun.co/docs/platform/reference/billing/getMyBilling

- **Operation ID:** `getMyBilling`
- **Tags:** Billing
- **Base URL:** `http://localhost:8787`

Plan, credit balance, subscription state, live credit lots and purchasable credit packs.

**Workflow:** [Integration guide](https://docs.spacerun.co/docs/platform/guides/billing-checkout).

**Authentication:** Platform user Bearer JWT. Acts only on the caller's own data.

## Authentication

- **Auth:** Platform user Bearer JWT (`Authorization: Bearer <access_token>`).

## Responses

### 200

Billing overview.

- Header `x-request-id`: Request identifier; quote it when reporting an error.
Content type: `application/json`

Schema: `object (MyBilling)`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `user_id` | `string<uuid>` | yes | - |
| `credits` | `string \| number` | yes | Current credit balance. |
| `tier_key` | `string` | yes | - |
| `tier_name` | `string` | yes | - |
| `ruleset_key` | `string \| null` | yes | - |
| `limits` | `object` | yes | Plan limits for the current tier. |
| `subscription_id` | `string \| null` | yes | - |
| `subscription_status` | `string \| null` | yes | - |
| `current_period_end` | `string \| null` | yes | - |
| `cancel_at_period_end` | `boolean \| null` | yes | - |
| `product_key` | `string \| null` | yes | - |
| `product_name` | `string \| null` | yes | - |
| `next_expiry` | `string \| null` | yes | - |
| `expiring_credits` | `string \| number` | yes | - |
| `version` | `string \| number` | yes | - |
| `updated_at` | `string` | yes | - |
| `lots` | `(object (MyCreditLot))[]` | yes | Live credit lots, soonest expiry first. |
| `lots[].id` | `string<uuid>` | yes | - |
| `lots[].source` | `string` | yes | - |
| `lots[].tier_key` | `string \| null` | yes | - |
| `lots[].granted` | `string \| number` | yes | - |
| `lots[].remaining` | `string \| number` | yes | - |
| `lots[].expires_at` | `string \| null` | yes | - |
| `lots[].created_at` | `string` | yes | - |
| `packs` | `(object (MyCreditPack))[]` | yes | Purchasable public credit packs. |
| `packs[].id` | `string<uuid>` | yes | - |
| `packs[].key` | `string` | yes | - |
| `packs[].name` | `string` | yes | - |
| `packs[].description` | `string \| null` | yes | - |
| `packs[].tier_key` | `string` | yes | - |
| `packs[].pack_credits` | `string \| number` | yes | - |
| `packs[].pack_bonus_credits` | `string \| number` | yes | - |
| `packs[].pack_expires_after` | `string \| null` | yes | - |
| `packs[].highlight` | `boolean` | yes | - |
| `packs[].badge` | `string \| null` | yes | - |
| `packs[].prices` | `object[]` | yes | - |
| `packs[].prices[].stripe_price_id` | `string` | yes | - |
| `packs[].prices[].currency` | `string \| null` | yes | - |
| `packs[].prices[].unit_amount` | `number \| null` | yes | - |

## Errors

### 401

Missing, malformed, expired or wrong-audience Bearer token (`missing_token`, `invalid_token`, `invalid_audience`).

- Header `x-request-id`: Request identifier; quote it when reporting an error.
Content type: `application/json`

Schema: `object (ErrorBody)`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes | Stable machine-readable error code, e.g. `forbidden`, `not_found`. |
| `details` | `any` | no | Optional structured context. For 403 it is `{ perm }`. |

**Error response**

```json
{
  "error": "missing_token"
}
```

### 404

`billing_not_found`: no billing record for the caller.

- Header `x-request-id`: Request identifier; quote it when reporting an error.
Content type: `application/json`

Schema: `object (ErrorBody)`, fields as described above.

**Error response**

```json
{
  "error": "billing_not_found"
}
```

### 500

Unexpected server error (`internal`). No details are returned.

- Header `x-request-id`: Request identifier; quote it when reporting an error.
Content type: `application/json`

Schema: `object (ErrorBody)`, fields as described above.

**Error response**

```json
{
  "error": "internal"
}
```

## Examples

### curl

```bash
curl -X GET 'http://localhost:8787/v1/me/billing' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

### TypeScript

```ts
const accessToken = process.env.ACCESS_TOKEN; // user JWT from your sign-in flow

const response = await fetch("http://localhost:8787/v1/me/billing", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${accessToken}`,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const data = response.status === 204 || response.status === 205
  ? undefined
  : response.headers.get("content-type")?.includes("json")
    ? await response.json()
    : await response.text();
```
