> ## 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.

# Usage events

> Ledger records every use once per request_id, however often it's retried, with its quantity, its outcome and the grants that paid for it.

Ledger keeps an exact, idempotent record of every use: each one is charged once, however often it's retried, and you can see which grants paid for it. `track` is how usage reaches Ledger. Each call is a **usage event**: one use of one feature by one customer, named by your `request_id`. Ledger decides it, spends the balance, and keeps the event as the record of what was used and what it cost. Refused calls are kept too, with their reason.

## What an event carries

| Field on `track` | Meaning |
| - | - |
| `customerId`, `featureId` | Who used what |
| `request_id` | Your ID for this one use, up to 255 characters |
| `quantity` | Units of the use in the feature's own units, a whole number, default 1. Metered: 1 or more. Held: signed, so `-1` removes one. Credits: Ledger charges `quantity × creditCost`. Not on boolean features |
| `count` | Held only: set the count outright, to reconcile with your app |
| `entityId` | Spend as an [entity](https://docs.integrateledger.com/customers/entities.md) inside the customer |

## One `request_id`, one charge

The `request_id` makes `track` idempotent. Use an ID you already store with the action: a message ID, a job ID, or a UUID you save with it.

* **A retry with the same ID** returns the first result with `"idempotent": true` and charges nothing more. That's how a lost response, or a queued track replayed after an [outage](https://docs.integrateledger.com/fail-open.md), stays charged once.
* **A new ID** records a second use.
* **It never expires.** A `request_id` is matched for as long as the customer exists, not for a window of hours: a retry next month is still a replay. (The `idempotencyKey` on upgrades, downgrades and balance adjustments is different: it matches for 24 hours.) IDs are scoped to one customer, so two customers can use the same one.
* **One ID belongs to one feature and entity.** Reusing it for another, of any type, returns `409 request_id_conflict`, not a replay.
* **A refused track charges nothing.** The same ID can succeed later, for example after the customer upgrades.

## Which period a use counts toward

A use counts toward the billing period that is current when Ledger records the track, at the customer's time. Ledger stamps each event itself, at the customer's time. A track recorded after a renewal spends the new period's allowance, and its overage goes on the next invoice, even if the work happened before the renewal.

So a fleet that buffers usage and sends it in batches should flush before each period ends. The period's end is `resetsAt` on a metered feature's `balance`, and `currentPlan.currentPeriodEnd` on the customer.

## Reading usage

| You need | Call | Returns |
| - | - | - |
| Tracked requests, newest first | [`GET /v1/usage`](https://docs.integrateledger.com/api-reference/usage/list) (`listUsage`) | Events, filtered by `customerId`, `status` (`success`, `failed`) and `month`, 25 a page |
| A month's counts | [`GET /v1/usage/totals`](https://docs.integrateledger.com/api-reference/usage/totals) (`getUsageTotals`) | `events`, `charged`, `blocked`, `failed`, `chargedCredits`, and refusals by reason |
| One event in full | [`GET /v1/usage/{id}`](https://docs.integrateledger.com/api-reference/usage/event) (`getUsageEvent`) | The event, each grant it drew from, and its overage |

Each event has an `outcome`: `charged`; `blocked` when the customer was out of balance or at their overage cap; or `failed` for any other refusal, such as an unknown feature. Its `reason` says why it wasn't charged. `occurredAt` is the customer's time, which [simulated time](https://docs.integrateledger.com/test/simulate-time.md) can move ahead, and `month` filters by it.

The usage log counts credits (`chargedCredits`, `overageCredits`). A metered or held use's units show in the feature's `balance` on the track response and the customer. Pages take `limit` up to 100 and the previous page's `nextCursor` as `cursor`.

**Usage** in the dashboard lists the same events, charged or blocked, and opening one shows which grants paid for it.

## Next steps

> [card] [Check and track](https://docs.integrateledger.com/customers/check-and-track.md)
>
> The calls, the refusals, and how to handle each.

> [card] [Invoices and Stripe](https://docs.integrateledger.com/concepts/invoices-and-stripe.md)
>
> How usage past the allowance reaches the invoice.


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