creditCost. A customer’s balance comes from current monthly plan allocations and purchased credit packs, minus recorded usage. Ledger spends monthly credits before credit-pack credits.
Check before running a feature
CallPOST /v1/check with customerId and featureId. The response includes allowed, availableCredits, and creditCost. A check reads the balance but does not reserve or consume credits.
Track completed usage
CallPOST /v1/track with the same customer and feature plus a unique request_id for the operation. Track makes a fresh decision in a transaction and, when allowed, records the charge. Retrying the same customer and request ID returns idempotent: true without charging again.
Always handle 409 insufficient_credits from track, even if a prior check returned allowed: true: the balance may have changed between the two calls. A request ID reused for a different feature returns 409 request_id_conflict.
Run both calls from your backend, where the Ledger key remains secret. See Integrate Ledger for a complete catalog and request sequence.