Credits
Consume Credits
Deduct credits from a tenant’s credit pool. Idempotent.
POST
Deducts credits from a tenant’s pool. Credits are deducted FIFO — base credits first, then add-on credits, earliest-expiry first.
Passing the same
idempotencyKey twice returns the original result without double-deducting.
Request Body
The credit pool to deduct from (e.g.
api_calls, ai_tokens). Must match a pool defined on the tenant’s active plan.Unique key for this consumption event. Duplicate calls with the same key return the original result — no double deduction.
Scope consumption to the tenant’s active subscription for this product (e.g.
ats). A tenant holds at most one active subscription per product, so this is the recommended way to disambiguate multi-product tenants. Without it, the most recently created active subscription is used.Scope consumption to an exact subscription ID. Takes effect together with
productSlug if both are passed (they must refer to the same subscription).Optional context stored on the event for auditing (e.g.
{ "endpoint": "/api/export", "userId": "u_123" }).Authentication
Requires a secret key (Authorization: Bearer sk_live_...).
Response
Outcome:
allowed, warning, or blocked.allowed— credits deducted successfullywarning— credits deducted, but this pool only tracks usage and is now over its allowanceblocked— not enough credits on a pool that blocks; nothing was deducted, andremainingis what is still left