How Credits Are Consumed
Monetary Credits
Monetary credits are applied while the invoice is priced:- Invoice is generated with line items
- System calculates the total for each line
- Available credits are applied in consumption order
- 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
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:- Priority — lowest number first
- Expiring grants before non-expiring ones
- Earliest expiry first
- Oldest grant first
0, so for those
the order comes down to expiry and then age.
Example
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 onPOST /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
Sendreserve: {} 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.
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
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
Sendaccount 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
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.Webhooks
Payload shapes are on the Credits Overview.
Next Steps
Wallets
Learn about prepaid wallets.
Credit Grants
Create and manage grants.