# API reference: billing

Pay as you go. There are no plans and no monthly fee. Every workspace gets a free amount each month. A workspace with a payment method pays for what it uses past that, once a month, up to the limit it set. Payments go through Stripe. On a hub that takes no payments, every workspace has the free amount only.

## POST /v1/billing/stripe-webhook

`receiveStripeWebhook` · scope `none` · Stripe's webhook

Where Stripe sends subscription and invoice events. The subscription is Stripe's monthly billing cycle. It has no fee of its own. The body is verified against the `Stripe-Signature` header with the endpoint's signing secret. An unsigned, mis-signed or stale event is `400`, and nothing changes.

Each event is handled once, by its id. A delivery Stripe repeats answers `200` with `duplicate: true`. Subscription events record whether a workspace has a payment method. An `invoice.created` adds the closed period's use to that month's invoice. A workspace that removes its payment method is invoiced at once for the use not yet billed. Its hosted runs and endpoints are asked to stop. Paid and failed invoices are recorded. `503` means this hub has no signing secret configured.

Parameters:

- `Stripe-Signature` (header, required)

Request body: `application/json`, required.

Responses:

- `200`: The event was handled, or was handled before.
- `400`: The signature does not prove the event came from Stripe.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## GET /v1/billing/prices

`getBillingPrices` · scope `none` · The hub's prices

How each kind of use is priced, what every workspace may use free each month, and the monthly limit a workspace starts with. There are no plans. The pricing page reads this. `configured` is false on a hub that takes no payments. No workspace can add a payment method there.

Responses:

- `200`: The free amount, the starting limit and the multipliers.
- `401`: Missing or invalid credentials.

## GET /v1/billing

`getBilling` · scope `key:read` · A workspace's use this period, what it will pay and its cap

Returns whether the workspace has a payment method, what it has used in the current billing period, its monthly cap and its invoices.

Use is priced at the hub's prices and grouped by AI model, GPU, sandbox and cloud CPU. A model call made with the workspace's own key is listed apart at $0. The free amount is used first. It covers AI models and the agent's sandbox. The next invoice charges the rest.

The period is the calendar month (UTC). The first period of a workspace starts on the day it added its payment method. The free amount is counted once a month, whatever happens to the payment method.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you belong to.

Responses:

- `200`: The workspace's billing.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## PUT /v1/billing/cap

`setBillingCap` · scope `session` · Set a workspace's monthly cap

Sets the most a workspace may spend in a billing period, counting every kind of use at the hub's prices. Use stops at the cap. A call or a job that would pass it answers `402`. Work already running keeps running.

Send `null` to remove the cap. Only a signed-in person sets a cap, so no key can raise its own. An organization's cap is set by its owners.

Until the workspace has paid an invoice, the cap cannot go above the one it started with, and it cannot be removed (`422`). `getBilling` gives that ceiling as `cap.max_cap_usd`.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you own.

Request body: `application/json`, required.

Responses:

- `200`: The cap, and where the period stands against it.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## POST /v1/billing/checkout

`createBillingCheckout` · scope `session` · Add a payment method

Opens a Stripe Checkout page that saves a payment method and returns its address. Nothing is charged there. The workspace pays for what it uses once Stripe confirms the method, at the end of each month. Only a signed-in person may start it. The first invoice comes on the first of the next month. `409` means the workspace already has a payment method. `503` means this hub takes no payments.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you own.

Responses:

- `200`: Where to send the person.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `502`: Stripe could not be reached or refused the request. Nothing changed. Try again in a moment.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## POST /v1/billing/portal

`createBillingPortal` · scope `session` · Open the Stripe customer portal

Opens Stripe's customer portal for the workspace and returns its address. A person changes the card, downloads invoices or removes the payment method there. Only a signed-in person may open it. `409` means the workspace never added a payment method. `503` means this hub takes no payments.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you own.

Responses:

- `200`: Where to send the person.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `502`: Stripe could not be reached or refused the request. Nothing changed. Try again in a moment.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.
