Skip to main content
Call jaza.consume() from your backend after a billable action. Pass a dashboard featureCode, raw credits, or both — plus an idempotency key so retries never double-charge. Never call consume from the client app. Pair UI gating with Gating actions (JazaActionButton), then enforce here.

Prerequisites

  • Features configured in the dashboard
  • A customer with a wallet (cus_…)
  • @jazadev/node with secretKey + publicKey

Fixed cost (feature default)

Variable cost (override)

Pass both featureCode and credits when usage varies (for example AI tokens). Jaza debits the override amount and still stores featureCode on the ledger:

Raw debit

Pass credits alone when you need an explicit amount without feature attribution:

Charge after success

Prefer deducting after the feature succeeds so failed work is not billed:

With ActionButton

Errors

The Node SDK throws JazaError with statusCode, code, and raw. Handle insufficient balance by prompting a top-up (Top-up). The client SDK may also open the paywall when Jaza signals insufficient credits over the client realtime channel. Successful and failed consumes can emit merchant webhooks (jaza.webhook.consumption.*). See Webhooks and Errors.

Idempotency

Use a key that is stable for the same business event (customer + feature + your action id). Do not use a fresh timestamp on every retry, or a timed-out success can deduct twice.

Next steps