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 external tenant ID from your application (e.g.
workspace_123)The credit pool to deduct from (e.g.
api_calls, ai_tokens). Must match a pool defined on the tenant’s active plan.Number of credits to consume. Must be a positive integer.
Unique key for this consumption event. Duplicate calls with the same key return the original result — no double deduction.
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_...) or service key (x-service-key).
Response
Outcome:
allowed, warning, or blocked.allowed— credits deducted successfullywarning— credits deducted but balance is now below zero (soft limit pool)blocked— insufficient credits on a hard limit pool; no deduction occurred
Credits remaining in the pool after this deduction.
true if this idempotencyKey was already processed. No deduction occurred on this call.The pool key that was targeted.