Skip to main content
Credits are consumed when invoices are produced and, for gated usage, in realtime as work happens. This guide explains the consumption mechanics and how to track credit usage.

How Credits Are Consumed

Monetary Credits

Monetary credits are applied while the invoice is priced:
  1. Invoice is generated with line items
  2. System calculates the total for each line
  3. Available credits are applied in consumption order
  4. Remaining balance is charged to a payment method

Unit Credits

Unit credits cover metered usage. They are drawn in two places:
  • At invoice time, against the metered lines the grant is allowed to pay for
  • In realtime, when a metric has a credit consumption configuration and the grant funds the gate — see The Realtime Gate
Usage sent to POST /events is metered but never draws credit. Only the gate endpoints charge credit for usage.

Consumption Order

When several grants can pay for the same charge, they are drawn in this order:
  1. Priority — lowest number first
  2. Expiring grants before non-expiring ones
  3. Earliest expiry first
  4. Oldest grant first
Priority is a dashboard setting on a subscription’s credit allocation, not an API field. Grants created manually or through the API are priority 0, so for those the order comes down to expiry and then age.

Example

A grant is only a candidate if it is eligible for the charge in the first place: it must belong to the customer, be within its validity window, and pass the product and price filters on the line being paid. See Credit Grants.

Invoice-Time Consumption

Credits are applied automatically as part of pricing an invoice; there is no opt-in and no separate “apply credits” call. While the invoice is a draft, each draw is written to the credit ledger as a pending entry, and re-pricing the draft re-synchronises those entries. When the invoice is finalized, the pending entries become final consumption. Voiding a draft removes them again, returning the credits to the grants they came from. Once an invoice closes, its consumption is frozen against that billing period. Settlement that arrives after the close is carried forward into the open period rather than reopening the closed one.

Ledger Entry Types

Every movement on a credit ledger records what caused it: Credit activity is visible per customer and per subscription in the dashboard.

The Realtime Gate

For work you want to authorise before doing it — an expensive inference run, a long job — the gate is a two-phase flow: reserve on POST /credits/check, settle on POST /credits/track. Neither request carries a credit amount. You describe the work as the events it will produce, and the response prices it per metric.
1

Reserve

POST /credits/check with reserve opens a hold and returns a reservation_id. An Idempotency-Key is required whenever reserve is set.
2

Do the work

The hold expires after 15 minutes unless ttl_seconds asks for longer, up to 4 hours. Each accepted settle slides the expiry forward.
3

Settle

POST /credits/track with the reservation_id, the events that actually happened, and close to say whether this is the final call.

Reserving

Send reserve: {} to hold exactly what the sampled events price to, or reserve: {"max_quantity": "..."} with an event_name for an open-ended ceiling in metric units.
Response:
Omit reserve for a cost-free quote: nothing is recorded, no credit moves, and charges still tells you what the work would price to.
Insufficient credit is not an error. The call returns 200 with allowed: false, and at_zero_action says what to do about it: stop for a hard deny, overflow to fall through to metered billing.

Settling

Response:
close is required whenever reservation_id is set — there is no default. Send close: false to report progress and keep the hold open, then close: true on the final call. Events sent to /credits/track are both metered and charged, so do not also send them to POST /events.

Drawing Without a Reservation

Send account instead of reservation_id to charge the account’s current credit directly, with no hold in between. close is not valid on a direct draw.

Reading a Reservation

The response reports the hold’s status, what it still has remaining, the metrics it covers, and every close already committed against it. It is a read: it cannot settle anything. Use it when a client has lost its Idempotency-Key and needs to discover what already landed instead of resending and burning twice.

Releasing Abandoned Work

If the work never happens, close the reservation with no events. Nothing is charged and the whole hold is released.
An abandoned hold that is never closed expires on its own.

Webhooks

Payload shapes are on the Credits Overview.

Next Steps

Wallets

Learn about prepaid wallets.

Credit Grants

Create and manage grants.