> ## Documentation Index
> Fetch the complete documentation index at: https://docs.caged.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Billing

> Manage subscriptions, checkout, and billing portal.

# Billing

Manage your subscription and billing through the API.

## Get Subscription

```bash theme={null}
curl https://api.caged.dev/v1/billing/subscription \
  -H "Authorization: Bearer caged_sk_..."
```

**Response** `200 OK`

```json theme={null}
{
  "plan": "pro",
  "status": "active",
  "current_period_end": "2026-07-08T00:00:00Z",
  "usage": {
    "compute_hours": 12.5,
    "llm_cost_usd": 3.42,
    "total_cost_usd": 5.67,
    "sandboxes_created": 8
  }
}
```

## Plans

| Plan       | Price   | Sandboxes     | Compute    | Support   |
| ---------- | ------- | ------------- | ---------- | --------- |
| Free       | \$0/mo  | 2 concurrent  | 10 hrs/mo  | Community |
| Pro        | \$29/mo | 10 concurrent | 100 hrs/mo | Email     |
| Team       | \$99/mo | 50 concurrent | 500 hrs/mo | Priority  |
| Enterprise | Custom  | Unlimited     | Custom     | Dedicated |

## Create Checkout Session

Creates a Stripe checkout session for subscription upgrade.

<ParamField body="plan" type="string" required>
  Plan to subscribe to: `pro`, `team`, or `enterprise`.
</ParamField>

```bash theme={null}
curl -X POST https://api.caged.dev/v1/billing/checkout \
  -H "Authorization: Bearer caged_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"plan": "pro"}'
```

**Response** `200 OK`

```json theme={null}
{
  "url": "https://checkout.stripe.com/c/pay/..."
}
```

## Create Billing Portal

Creates a Stripe billing portal link for managing payment methods, invoices, and plan changes.

```bash theme={null}
curl -X POST https://api.caged.dev/v1/billing/portal \
  -H "Authorization: Bearer caged_sk_..."
```

**Response** `200 OK`

```json theme={null}
{
  "url": "https://billing.stripe.com/p/session/..."
}
```

## Cancel Subscription

Cancels the subscription at the end of the current billing period.

```bash theme={null}
curl -X POST https://api.caged.dev/v1/billing/cancel \
  -H "Authorization: Bearer caged_sk_..."
```

**Response** `200 OK`

```json theme={null}
{
  "status": "canceled",
  "effective_at": "2026-07-08T00:00:00Z"
}
```
