You need a root key with the permissions listed on this page. Create one in the dashboard under Settings > Root Keys, and pass it as
Authorization: Bearer <root key>. See Permission reference for every permission.Give the key a monthly allowance
credits.remaining is the balance and credits.refill resets it on a schedule. A monthly refill needs a refillDay (in shorter months it runs on the last day). A refill resets the balance to refill.amount rather than adding to it, so unused credits don’t roll over.
10,000 requests a month, reset on the 1st
Charge per operation
Each verification spendscredits.cost, 1 by default. Set the cost per operation: a bulk export might cost 50 and a status check 0. A request that fails any other check, such as a rate limit or permission, spends nothing.
src/billing.ts
X-Credits-Remaining so customers can see it. Analytics records the credits spent per key and identity, so you can build invoices from it.
Sell top-ups and change plans
keys.updateCredits changes the balance and leaves the refill schedule alone. Use increment when a customer buys credits, decrement to take some back, and set for a new balance. set with value: null makes the key unlimited, for example for an enterprise plan with no cap.
keys.updateKey with a new credits.refill.amount. It applies at the next refill.
Related
- Credits and refill for every field and the refill schedule.
- Verifying keys for why credits are checked last.
- Tiered subscriptions for combining credits with limits and permissions per plan.