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

> Cap use over a day, a week, a month or the billing period, on one feature, one model or the whole credit pool, enforced on every check and track.

> **Pro:** 1,000 messages a month, never more than 200 a day. **Scale:** 5,000 credits a period, at most 1,000 of them on GPT-4 each day.

Usage limits pace how a customer spends what they have. A plan grants the allowance; a usage limit caps how much of it any one day, week or month may use, so a runaway script, a shared key or one heavy afternoon can't drain a month's allowance or run up your model bill. Ledger counts every window on the same `check` and `track` calls you already make, and refuses the use that would pass a limit before anything is charged.

## The catalog

Limits go in a plan's `controls.usageLimits`, and apply to everyone on the plan:

```ts ledger.config.ts theme={"system"}
import { defineCatalog, feature, plan } from "integrateledger-cli";

export default defineCatalog({
	features: [
		feature({ id: "messages", name: "Messages", type: "metered" }),
		feature({ id: "chat", name: "Chat", creditCost: 1 }),
	],
	plans: [
		plan({
			id: "pro",
			name: "Pro",
			monthlyCredits: 0,
			priceCents: 2900,
			items: [{ featureId: "messages", included: 1000 }],
			controls: {
				usageLimits: [{ featureId: "messages", limit: 200, interval: "day" }],
			},
		}),
		plan({
			id: "scale",
			name: "Scale",
			monthlyCredits: 5000,
			priceCents: 9900,
			items: [],
			controls: {
				usageLimits: [
					{ creditPool: true, limit: 1000, interval: "day", filter: { model: "gpt-4" } },
				],
			},
		}),
	],
	creditPacks: [],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "messages", "name": "Messages", "type": "metered" },
    { "id": "chat", "name": "Chat", "creditCost": 1 }
  ],
  "plans": [
    { "id": "pro", "name": "Pro", "monthlyCredits": 0, "priceCents": 2900,
      "items": [{ "featureId": "messages", "included": 1000 }],
      "controls": { "usageLimits": [{ "featureId": "messages", "limit": 200, "interval": "day" }] } },
    { "id": "scale", "name": "Scale", "monthlyCredits": 5000, "priceCents": 9900, "items": [],
      "controls": { "usageLimits": [
        { "creditPool": true, "limit": 1000, "interval": "day", "filter": { "model": "gpt-4" } }
      ] } }
  ],
  "addOns": []
}
```

| Field | |
| - | - |
| `featureId` or `creditPool: true` | What the limit counts. A credits feature counts its uses (the track's `quantity`), a metered feature counts units (on unlimited items too), and `creditPool: true` counts the credits every credits feature draws, overage included. |
| `limit` | The most one window may use, above 0. |
| `interval` | The window: `day`, `week` (from Monday), `month` or `billing_period`. |
| `anchor` | Where windows start: `utc` calendar boundaries, or `billing_cycle`, counted from the subscription's billing anchor. Day and week default to `utc`, and month to `billing_cycle`. |
| `filter` | Count only the uses whose `properties` hold every pair, such as `{ "model": "gpt-4" }`. |

## Windows

Each limit counts in its own window, and the count starts again when the window ends:

* **`day` and `week`** follow UTC calendar days and Monday-start weeks. With `anchor: "billing_cycle"`, they count in 24-hour and 7-day steps from the billing anchor instead.
* **`month`** counts from the billing anchor, so a customer who subscribed on the 14th resets on the 14th. With `anchor: "utc"`, it follows the calendar month.
* **`billing_period`** is the subscription's own period, monthly or yearly.

Windows run on the customer's time, so a [test clock](https://docs.integrateledger.com/test/simulate-time.md) moves them, and a customer with no plan counts every window in UTC.

## Several limits at once

Stack limits to shape use at every scale: a monthly allowance with a daily ceiling, a pool limit beside a per-model one, a plan's limit and a customer's own. Every limit that counts a use applies together, and the use must fit all of them.

* **Per target, interval and filter.** A plan can hold one limit for each combination: `messages` per day and `messages` per week are two limits; two `messages` per day limits are one too many.
* **Customer and entity limits.** Give one customer, or one of their [entities](https://docs.integrateledger.com/customers/entities.md), their own limits with [`POST /v1/customers/controls`](https://docs.integrateledger.com/customers/overrides#overage-controls). A customer's limit replaces the plan's with the same target, interval and filter, and an entity's replaces the customer's.
* **Entities inside customers.** An entity's own limit counts that entity's use, inside the customer's limit, which counts everyone's.

## Properties and filters

Send `properties` with a `check` or `track` to describe the use, and a limit with a `filter` counts only the uses that match:

```typescript TypeScript theme={"system"}
await billing.trackUsage({
	customerId: "user_123",
	featureId: "chat",
	requestId: "chat_0193",
	quantity: 40,
	properties: { model: "gpt-4", region: "eu" },
});
```

```python Python theme={"system"}
billing.track_usage(
    customer_id="user_123",
    feature_id="chat",
    request_id="chat_0193",
    quantity=40,
    properties={"model": "gpt-4", "region": "eu"},
)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/track \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "user_123", "featureId": "chat", "request_id": "chat_0193", "quantity": 40, "properties": {"model": "gpt-4", "region": "eu"}}'
```

This use counts toward `{ "model": "gpt-4" }` and toward any limit with no filter. Values match by type and value, so `true` and `"true"` are different, and numbers compare as numbers. Properties are matched against filters only; Ledger doesn't store them.

## What check and track return

A use that fits every limit is answered as usual. The use that would pass one is refused whole, before anything is charged or counted:

```json Response (409) theme={"system"}
{
  "error": "usage_limit_reached",
  "message": "This use would pass a usage limit's window for customer \"user_123\" (see usageLimit); nothing was charged or counted. Wait until usageLimit.resetsAt, or raise the limit with POST /v1/customers/controls.",
  "usageLimit": {
    "featureId": "messages",
    "interval": "day",
    "limit": 200,
    "used": 195,
    "resetsAt": "2026-11-24T00:00:00.000Z",
    "filter": null,
    "source": "plan"
  }
}
```

`used` is the window's use before this one, reservations still held included, and `source` says which level set the limit: `plan`, `customer` or `entity`. `check` answers `allowed: false` with `reason: "usage_limit_reached"` and the same `usageLimit`, so your app can say "You've reached today's limit; it resets at midnight UTC" before the work starts. Read every limit in force, with its `used`, `remaining` and `resetsAt`, from [`GET /v1/customers/controls`](https://docs.integrateledger.com/api-reference/customers/get-controls).

## Rules

* **All or nothing.** A use that would pass a limit is refused whole, an AI token call included, even where the balance would cover part of it; one that lands exactly on it is allowed.
* **Balance first.** A customer out of credits gets `insufficient_credits`, and one past their allowance `limit_reached`, before any usage limit is counted.
* **Reservations count while held.** A [reservation's](https://docs.integrateledger.com/customers/reservations.md) hold counts toward the window, on credits and metered features alike. A settle at or below the hold always succeeds and frees the rest; one above it must fit, or it's refused whole with `409 usage_limit_reached` and the hold kept.
* **Overage stops at the limit.** Use a limit refuses is never billed, so a daily cap on a metered item with overage caps its overage bill too.
* **Changes apply at once.** Limits change in place for everyone on the plan, with no new version. A limit lowered below what's used refuses the next use, and a new limit starts counting at 0. A [draft's](https://docs.integrateledger.com/billing/plan-versions.md#prepare-a-draft) limits change in place too, and promoting the draft makes them the plan's.
* **Credits and metered features.** A limit targets a credits feature, a metered feature or the pool, once per target, interval and filter (`400 invalid_usage_limit` from `POST /v1/customers/controls`). [Held](https://docs.integrateledger.com/pricing/limits.md) and [boolean](https://docs.integrateledger.com/pricing/feature-flags.md) features have limits of their own.
* **Properties.** Up to 20 keys of 1 to 64 characters, each a string (up to 255 characters), a number or a boolean.
* **Up to 50** limits on each plan, customer or entity.

## Related

* [Usage alerts](https://docs.integrateledger.com/pricing/usage-alerts.md): a webhook as a customer nears a limit or their allowance.
* [Overage](https://docs.integrateledger.com/pricing/overage.md#overage-controls): overage off, a free buffer, or recorded but not billed.
* [Overrides](https://docs.integrateledger.com/customers/overrides.md#overage-controls): one customer's or entity's own controls.
* [Metered allowances](https://docs.integrateledger.com/pricing/metered.md) and [Credits](https://docs.integrateledger.com/pricing/credits.md): the allowances limits pace.


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