---
title: "Billing API reference"
url: "https://coldagentai.com/docs/api/billing.md"
canonical_url: "https://coldagentai.com/docs/api/billing"
last_updated: "2026-10-31"
type: "reference"
summary: "Start Stripe Checkout, open the billing portal and read billing state with the ColdAgentAI API, plus the route Stripe calls with signed events."
related: ["https://coldagentai.com/docs/api.md", "https://coldagentai.com/docs/authentication.md", "https://coldagentai.com/docs/errors.md", "https://coldagentai.com/docs/api/accounts.md", "https://coldagentai.com/docs/api/credits.md"]
install: "claude mcp add --transport http coldagentai-free https://coldagentai.com/api/mcp"
---

# Billing API reference

> **For AI agents:** the complete index of ColdAgentAI pages is [llms.txt](https://coldagentai.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Start Stripe Checkout, open the billing portal and read billing state with the ColdAgentAI API, plus the route Stripe calls with signed events.

Start a Stripe Checkout, open the billing portal and read billing state. Stripe calls the webhook route with signed events; no request body sets a plan, a price or a credit count. 5 operations.

## Operations

Authenticate as described in [Authentication](https://coldagentai.com/docs/authentication.md). Every operation below is generated from the [OpenAPI document](https://coldagentai.com/docs/openapi.md).

| Method and path | Scope | What it does |
| --- | --- | --- |
| `POST /v1/billing/checkout` | write | Start a Stripe checkout for a plan or a credit pack |
| `POST /v1/billing/start-plan` | write | Start my plan now (ends the trial early) |
| `POST /v1/billing/portal` | write | Open the Stripe customer portal |
| `GET /v1/billing` | read | Plan, invoices and what can be bought |
| `POST /v1/billing/webhook` | public | Stripe webhook receiver |

## POST /v1/billing/checkout

Creates a Stripe Checkout Session and returns its url. A plan checkout bills monthly or annually (annual is 10 months for 12) and, while the account is eligible (it never held a plan and its trial was not used), starts with a 7-day trial that costs $1 at signup (a one-time line beside the plan, cards only) and charges the plan nothing until the trial ends (it grants 12 credits in place of plan credits, and they end with the trial); a credit pack is one of the sizes 1000, 2000, 3000, 4000, 5000, 10000, 20000, 50000, 100000 credits and never expires. A first paid month can be refunded within 7 days; a person decides each refund. Credits and the plan arrive only after Stripe confirms payment. Returns 409 conflict when the account already has a subscription, and 503 provider_unavailable with the fix named when Stripe or the return site is not configured.

Scope: `write`. A read key gets 403 forbidden. Success: HTTP 201.

### Request body

Send JSON with `Content-Type: application/json`. The body is required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | "plan" | yes | No further constraints. |
| `plan_id` | "starter" or "pro" or "max" or "enterprise" | yes | starter, pro, max. Enterprise is set up on a call and is refused here with the booking page named. |
| `interval` | "monthly" or "annual" | no | annual bills 10 months for 12. Default "monthly". |
| `success_url` | string (uri) | yes | Where Stripe sends the customer after paying. Must be on this service's own site. 0 to 2048 characters. |
| `cancel_url` | string (uri) | yes | Where Stripe sends the customer if they leave checkout. Must be on this service's own site. 0 to 2048 characters. |
| `attempt_id` | string | no | A random id your client makes once per buy and sends again on every retry of it. A repeat with the same id returns the same Checkout instead of making another. |

Request example:

```
{
  "kind": "plan",
  "plan_id": "starter",
  "success_url": "https://example.com/welcome",
  "cancel_url": "https://example.com/pricing"
}
```

### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `session_id` | string | yes | No further constraints. |
| `url` | string | yes | No further constraints. |
| `amount_cents` | integer | yes | The price, at the working prices: per billing interval for a plan, once for a credit pack. |
| `trial_days` | integer or null | yes | Days of trial this session really gives before the plan first charges; null when it gives none (a credit pack, or an account whose trial was used or that held a plan, which pays the plan from the start). |
| `trial_fee_cents` | integer or null | yes | What this session's trial costs at signup, charged once to the card; null when the session gives no trial. |
| `pricing_status` | "owner-approved" | yes | No further constraints. |

Response example, HTTP 201:

```
{
  "session_id": "id_8f3a2c1d",
  "url": "abc123",
  "amount_cents": 1,
  "trial_days": 1,
  "trial_fee_cents": 1,
  "pricing_status": "owner-approved"
}
```

### Errors

[`invalid_input`](https://coldagentai.com/docs/errors.md#invalid_input), [`unauthorized`](https://coldagentai.com/docs/errors.md#unauthorized), [`forbidden`](https://coldagentai.com/docs/errors.md#forbidden), [`conflict`](https://coldagentai.com/docs/errors.md#conflict), [`payload_too_large`](https://coldagentai.com/docs/errors.md#payload_too_large), [`rate_limited`](https://coldagentai.com/docs/errors.md#rate_limited), [`internal_error`](https://coldagentai.com/docs/errors.md#internal_error), [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable). Every error uses the [single format](https://coldagentai.com/docs/errors.md#format).

### Rate limits

Counted per key: 200 requests per 10 seconds. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. Over the limit the answer is `429 rate_limited` with `Retry-After`. See [Rate limits](https://coldagentai.com/docs/rate-limits.md).

### Examples

cURL:

```
curl -X POST "https://api.coldagentai.com/v1/billing/checkout" \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "plan",
  "plan_id": "starter",
  "success_url": "https://example.com/welcome",
  "cancel_url": "https://example.com/pricing"
}'
```

JavaScript (fetch):

```
const res = await fetch(`https://api.coldagentai.com/v1/billing/checkout`, {
  method: 'POST',
  body: JSON.stringify({
    "kind": "plan",
    "plan_id": "starter",
    "success_url": "https://example.com/welcome",
    "cancel_url": "https://example.com/pricing"
  }),
  headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' },
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
const data = await res.json();
```

## POST /v1/billing/start-plan

The customer's own click. Ends the running trial now, so the plan's first invoice is raised and charged at once and the plan's full credits and caps start. Nothing else ever starts the plan early: a used-up trial allowance only pauses credit spending (trial_allowance_exhausted). Answers 409 when the account has no running trial. A read key cannot do this.

Scope: `write`. A read key gets 403 forbidden. Success: HTTP 200.

### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `started` | true | yes | No further constraints. |

Response example, HTTP 200:

```
{
  "started": true
}
```

### Errors

[`unauthorized`](https://coldagentai.com/docs/errors.md#unauthorized), [`forbidden`](https://coldagentai.com/docs/errors.md#forbidden), [`conflict`](https://coldagentai.com/docs/errors.md#conflict), [`rate_limited`](https://coldagentai.com/docs/errors.md#rate_limited), [`internal_error`](https://coldagentai.com/docs/errors.md#internal_error), [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable). Every error uses the [single format](https://coldagentai.com/docs/errors.md#format).

### Rate limits

Counted per key: 200 requests per 10 seconds. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. Over the limit the answer is `429 rate_limited` with `Retry-After`. See [Rate limits](https://coldagentai.com/docs/rate-limits.md).

### Examples

cURL:

```
curl -X POST "https://api.coldagentai.com/v1/billing/start-plan" \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY"
```

JavaScript (fetch):

```
const res = await fetch(`https://api.coldagentai.com/v1/billing/start-plan`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}` },
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
const data = await res.json();
```

## POST /v1/billing/portal

Returns a Stripe customer portal url for this account, where the customer changes the card, reads invoices and cancels. A cancel ends the plan at the end of the period already paid for, with no reason asked. Send `flow: "cancel"` to open straight on the cancel step for the running plan (one click to confirm); 404 when there is no running plan to cancel. The account needs a Stripe customer, which a checkout creates.

Scope: `write`. A read key gets 403 forbidden. Success: HTTP 200.

### Request body

Send JSON with `Content-Type: application/json`. The body is required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `return_url` | string (uri) | yes | Where the portal sends the customer back to. Must be on this service's own site. 0 to 2048 characters. |
| `flow` | "cancel" | no | "cancel" opens straight on the cancel step for the running plan. Left out, the portal opens on its home page. |

Request example:

```
{
  "return_url": "https://example.com/path"
}
```

### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | yes | No further constraints. |

Response example, HTTP 200:

```
{
  "url": "abc123"
}
```

### Errors

[`invalid_input`](https://coldagentai.com/docs/errors.md#invalid_input), [`unauthorized`](https://coldagentai.com/docs/errors.md#unauthorized), [`forbidden`](https://coldagentai.com/docs/errors.md#forbidden), [`not_found`](https://coldagentai.com/docs/errors.md#not_found), [`payload_too_large`](https://coldagentai.com/docs/errors.md#payload_too_large), [`rate_limited`](https://coldagentai.com/docs/errors.md#rate_limited), [`internal_error`](https://coldagentai.com/docs/errors.md#internal_error), [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable). Every error uses the [single format](https://coldagentai.com/docs/errors.md#format).

### Rate limits

Counted per key: 200 requests per 10 seconds. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. Over the limit the answer is `429 rate_limited` with `Retry-After`. See [Rate limits](https://coldagentai.com/docs/rate-limits.md).

### Examples

cURL:

```
curl -X POST "https://api.coldagentai.com/v1/billing/portal" \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "return_url": "https://example.com/path"
}'
```

JavaScript (fetch):

```
const res = await fetch(`https://api.coldagentai.com/v1/billing/portal`, {
  method: 'POST',
  body: JSON.stringify({
    "return_url": "https://example.com/path"
  }),
  headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' },
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
const data = await res.json();
```

## GET /v1/billing

The account's plan and subscription state, its recent invoices and the offers on sale, from the local copy of Stripe's state. Never calls Stripe.

Scope: `read`. A read key and a write key both work. Success: HTTP 200.

### Response

Response example, HTTP 200:

```
{
  "example_key": {}
}
```

### Errors

[`unauthorized`](https://coldagentai.com/docs/errors.md#unauthorized), [`rate_limited`](https://coldagentai.com/docs/errors.md#rate_limited), [`internal_error`](https://coldagentai.com/docs/errors.md#internal_error), [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable). Every error uses the [single format](https://coldagentai.com/docs/errors.md#format).

### Rate limits

Counted per key: 200 requests per 10 seconds. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. Over the limit the answer is `429 rate_limited` with `Retry-After`. See [Rate limits](https://coldagentai.com/docs/rate-limits.md).

### Examples

cURL:

```
curl "https://api.coldagentai.com/v1/billing" \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY"
```

JavaScript (fetch):

```
const res = await fetch(`https://api.coldagentai.com/v1/billing`, {
  headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}` },
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
const data = await res.json();
```

## POST /v1/billing/webhook

Public endpoint for Stripe. The signature over the exact raw body is verified first (5 minute tolerance); a bad signature answers 400 signature_invalid and writes nothing. A verified event is applied once, in one transaction with its record: a paid subscription invoice grants that period's plan credits, a paid credit pack grants top-up credits, subscription events update the plan, and a dispute is queued for review. A replay answers 200 and changes nothing.

Scope: `public`. No API key is needed. Success: HTTP 200.

### Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `received` | true | yes | No further constraints. |
| `outcome` | "applied" or "duplicate" or "ignored" or "ignored_foreign_brand" or "ignored_wrong_mode" or "needs_review" | yes | No further constraints. |
| `type` | string | yes | No further constraints. |
| `detail` | string or null | yes | No further constraints. |

Response example, HTTP 200:

```
{
  "received": true,
  "outcome": "applied",
  "type": "abc123",
  "detail": "abc123"
}
```

### Errors

[`signature_invalid`](https://coldagentai.com/docs/errors.md#signature_invalid), [`payload_too_large`](https://coldagentai.com/docs/errors.md#payload_too_large), [`internal_error`](https://coldagentai.com/docs/errors.md#internal_error), [`provider_unavailable`](https://coldagentai.com/docs/errors.md#provider_unavailable). Every error uses the [single format](https://coldagentai.com/docs/errors.md#format).

### Rate limits

Never refused for load: this operation is not rate limited. See [Rate limits](https://coldagentai.com/docs/rate-limits.md).

### Examples

cURL:

```
curl -X POST "https://api.coldagentai.com/v1/billing/webhook"
```

JavaScript (fetch):

```
const res = await fetch(`https://api.coldagentai.com/v1/billing/webhook`, {
  method: 'POST',
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
const data = await res.json();
```

## Related

- [API reference](https://coldagentai.com/docs/api.md)
- [API authentication](https://coldagentai.com/docs/authentication.md)
- [API errors](https://coldagentai.com/docs/errors.md)
- [Accounts API reference](https://coldagentai.com/docs/api/accounts.md)
- [Credits API reference](https://coldagentai.com/docs/api/credits.md)
