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

# Usage-based billing

> Meter usage with events, bill per unit or from prepaid credits.

Send usage events, and SleetPay meters them against your pricing: per unit, graduated or volume tiers, or against **prepaid credits**.

## 1. Create a meter

In the dashboard, create a meter that watches an event name (for example `llm.call`), aggregates a numeric property with `sum`, `max` or `count` (`count` needs no property), and has a unit label (for example `tokens`). Pricing is per million units with an optional free allowance per period, and can be flat, graduated or volume tiered. Attach the meter to a product, or use it with a prepaid credits benefit.

## 2. Send events

```ts theme={null}
await sleetpay.events.ingest({
  name: "llm.call",
  externalCustomerId: user.id,
  properties: { tokens: 1200 },
  idempotencyKey: requestId, // required
});
```

Send up to 500 at once by passing an array. `properties` take up to 50 numeric values. `timestamp` is optional (ISO 8601 with offset) and defaults to now.

> [!TIP]
>
> **Idempotency is mandatory**
>
> Resending an event with the same `idempotencyKey` never double-counts, so retry freely on timeouts. Use a stable id from your own system, such as a request id.

The response lists a `status` per event. When a prepaid customer has too few credits the API answers `402` with the per-event results.

## 3. Read balances

```ts theme={null}
const { balances } = await sleetpay.credits.balance(user.id); // [{ unitLabel: "tokens", units: 48800 }]
```

Or read `active_meters` from [`customers.state`](https://docs.sleetpay.com/guides/customers).

## Transfer credits

A team admin handing a teammate part of a pack:

```ts theme={null}
await sleetpay.credits.transfer({ from: adminId, to: teammateId, units: 5000, idempotencyKey: "xfer_123" });
```

Atomic, never overdraws (`402` with `available`), and safe to retry with the same `idempotencyKey`. The recipient is created on first use. Needs `credits:write`.

## Related

* [API reference](https://docs.sleetpay.com/api-reference/introduction.md), [API reference](https://docs.sleetpay.com/api-reference/introduction.md)


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