> ## Documentation Index
> Fetch the complete documentation index at: https://docs.integrateledger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Credits and usage

> Check availability and record each successful feature use.

Each feature in your catalog has a `creditCost`. A customer's balance comes from current monthly plan allocations and purchased credit packs, minus recorded usage. Ledger spends monthly credits before credit-pack credits.

## Check before running a feature

Call `POST /v1/check` with `customerId` and `featureId`. The response includes `allowed`, `availableCredits`, and `creditCost`. A check reads the balance but does not reserve or consume credits.

## Track completed usage

Call `POST /v1/track` with the same customer and feature plus a unique `request_id` for the operation. Track makes a fresh decision in a transaction and, when allowed, records the charge. Retrying the same customer and request ID returns `idempotent: true` without charging again.

Always handle `409 insufficient_credits` from track, even if a prior check returned `allowed: true`: the balance may have changed between the two calls. A request ID reused for a different feature returns `409 request_id_conflict`.

Run both calls from your backend, where the Ledger key remains secret. See [Integrate Ledger](https://docs.integrateledger.com/quickstart.md) for a complete catalog and request sequence.

To try the same decision path before integrating your backend, open **Customers → Usage** in the dashboard. Select a sandbox customer and feature, check the balance, then record an event with a unique request ID. Retrying that ID shows an idempotent result. The dashboard uses the same credit transaction logic as the public API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.