Billing API reference

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.

For AI agents: the docs index is at /llms.txt, and every page is also served as markdown at its URL plus .md.

#Operations

Authenticate as described in Authentication. Every operation below is generated from the OpenAPI document.

Method and pathScopeWhat it does
POST /v1/billing/checkoutwriteStart a Stripe checkout for a plan or a credit pack
POST /v1/billing/start-planwriteStart my plan now (ends the trial early)
POST /v1/billing/portalwriteOpen the Stripe customer portal
GET /v1/billingreadPlan, invoices and what can be bought
POST /v1/billing/webhookpublicStripe 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.

FieldTypeRequiredDescription
kind"plan"yesNo further constraints.
plan_id"starter" or "pro" or "max" or "enterprise"yesstarter, pro, max. Enterprise is set up on a call and is refused here with the booking page named.
interval"monthly" or "annual"noannual bills 10 months for 12. Default "monthly".
success_urlstring (uri)yesWhere Stripe sends the customer after paying. Must be on this service's own site. 0 to 2048 characters.
cancel_urlstring (uri)yesWhere Stripe sends the customer if they leave checkout. Must be on this service's own site. 0 to 2048 characters.
attempt_idstringnoA 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

FieldTypeRequiredDescription
session_idstringyesNo further constraints.
urlstringyesNo further constraints.
amount_centsintegeryesThe price, at the working prices: per billing interval for a plan, once for a credit pack.
trial_daysinteger or nullyesDays 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_centsinteger or nullyesWhat this session's trial costs at signup, charged once to the card; null when the session gives no trial.
pricing_status"owner-approved"yesNo 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, unauthorized, forbidden, conflict, payload_too_large, rate_limited, internal_error, provider_unavailable. Every error uses the single 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.

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

FieldTypeRequiredDescription
startedtrueyesNo further constraints.
Response example, HTTP 200
{
  "started": true
}

Errors

unauthorized, forbidden, conflict, rate_limited, internal_error, provider_unavailable. Every error uses the single 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.

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.

FieldTypeRequiredDescription
return_urlstring (uri)yesWhere 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

FieldTypeRequiredDescription
urlstringyesNo further constraints.
Response example, HTTP 200
{
  "url": "abc123"
}

Errors

invalid_input, unauthorized, forbidden, not_found, payload_too_large, rate_limited, internal_error, provider_unavailable. Every error uses the single 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.

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, rate_limited, internal_error, provider_unavailable. Every error uses the single 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.

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

FieldTypeRequiredDescription
receivedtrueyesNo further constraints.
outcome"applied" or "duplicate" or "ignored" or "ignored_foreign_brand" or "ignored_wrong_mode" or "needs_review"yesNo further constraints.
typestringyesNo further constraints.
detailstring or nullyesNo further constraints.
Response example, HTTP 200
{
  "received": true,
  "outcome": "applied",
  "type": "abc123",
  "detail": "abc123"
}

Errors

signature_invalid, payload_too_large, internal_error, provider_unavailable. Every error uses the single format.

Rate limits

Never refused for load: this operation is not rate limited. See Rate limits.

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();
Billing