Skip to main content
Ledger keeps an exact, idempotent record of every use: each one is charged once, however often it’s retried, and you can see which grants paid for it. track is how usage reaches Ledger. Each call is a usage event: one use of one feature by one customer, named by your request_id. Ledger decides it, spends the balance, and keeps the event as the record of what was used and what it cost. Refused calls are kept too, with their reason.

What an event carries

One request_id, one charge

The request_id makes track idempotent. Use an ID you already store with the action: a message ID, a job ID, or a UUID you save with it.
  • A retry with the same ID returns the first result with "idempotent": true and charges nothing more. That’s how a lost response, or a queued track replayed after an outage, stays charged once.
  • A new ID records a second use.
  • It never expires. A request_id is matched for as long as the customer exists, not for a window of hours: a retry next month is still a replay. (The idempotencyKey on upgrades, downgrades and balance adjustments is different: it matches for 24 hours.) IDs are scoped to one customer, so two customers can use the same one.
  • One ID belongs to one feature and entity. Reusing it for another, of any type, returns 409 request_id_conflict, not a replay.
  • A refused track charges nothing. The same ID can succeed later, for example after the customer upgrades.

Which period a use counts toward

A use counts toward the billing period that is current when Ledger records the track, at the customer’s time. Ledger stamps each event itself, at the customer’s time. A track recorded after a renewal spends the new period’s allowance, and its overage goes on the next invoice, even if the work happened before the renewal. So a fleet that buffers usage and sends it in batches should flush before each period ends. The period’s end is resetsAt on a metered feature’s balance, and currentPlan.currentPeriodEnd on the customer.

Reading usage

Each event has an outcome: charged; blocked when the customer was out of balance or at their overage cap; or failed for any other refusal, such as an unknown feature. Its reason says why it wasn’t charged. occurredAt is the customer’s time, which simulated time can move ahead, and month filters by it. The usage log counts credits (chargedCredits, overageCredits). A metered or held use’s units show in the feature’s balance on the track response and the customer. Pages take limit up to 100 and the previous page’s nextCursor as cursor. Usage in the dashboard lists the same events, charged or blocked, and opening one shows which grants paid for it.

Next steps

Check and track

The calls, the refusals, and how to handle each.

Invoices and Stripe

How usage past the allowance reaches the invoice.