# Rate limits

What happens when you send too many requests, and how to back off.

## When you are limited

A request over the limit answers `429` with the code `rate_limited` and a `Retry-After` header holding the number of seconds to wait.

```http title="429"
HTTP/1.1 429 Too Many Requests
Retry-After: 12
Content-Type: application/json

{ "error": { "code": "rate_limited", "message": "too many requests" } }
```

Wait that long, then retry. The SDK does this for you: it waits for `Retry-After` and retries requests that are safe to repeat.

## Limits

- Each API key: 1000 requests a minute, counted per key. Keys do not share a budget, even when one person created them all. A request a key is not allowed to make still counts against it.
- A publishable key is counted per key and per visitor IP address, so one visitor cannot use up a pricing table's budget for everyone else.
- Requests carrying a key, from one IP address: 3000 a minute, checked before the key is looked up. Invalid keys from one address are looked up at most 300 times a minute.
- Signed-in dashboard requests: 120 a minute per person.
- Requests from one IP address before authentication: 300 a minute.
- The hosted checkout and portal pages have their own limit of 120 a minute per IP address, and invoice pay links 30 a minute.

Treat these as a ceiling, not a target. If the limiter itself is unavailable, requests are allowed through.

## Rate limit headers

Every authenticated response carries the state of the budget that governed it:

| Header | Meaning |
| --- | --- |
| `X-RateLimit-Limit` | Requests allowed in the current one-minute window. |
| `X-RateLimit-Remaining` | Requests left in the window. |
| `X-RateLimit-Reset` | When the window resets, as Unix time in seconds. |

Slow down when `X-RateLimit-Remaining` gets low instead of waiting for a 429.

## Staying under the limit

- Report usage in batches. `mint.usage.report()` queues events and sends up to 100 at a time.
- Read entitlements through the SDK. It caches each customer's snapshot for 60 seconds and refreshes it from the `entitlements.updated` webhook.
- React to webhooks instead of polling for changes.
