Credit Pool Fields
Credit Sources
A tenant’s balance in a pool comes from two sources:The Ledger
Credits are tracked in a double-entry ledger table (tenant_credit_ledger). Each entry records:
qty_granted— credits issued at the time of grantqty_remaining— credits not yet consumed (decremented on usage)source_type—baseoraddonexpires_at— when these credits expire
Checking Balance
productSlug to select the product’s subscription; otherwise the most recently created active subscription is used.
Recording Consumption
Callcredits/consume from your backend whenever a tenant consumes a credit. Every call requires an idempotencyKey — passing the same key twice returns the original result without double-deducting. It accepts the same optional productSlug scoping as the balance endpoint.
Hard vs Soft Limits
Use
check-usage-limit to gate actions before consuming:
Rollover Example
A plan withai_tokens: 1000/month, refill_behavior: rollover, rollover_cap: 500: