# Rate limits

> How many calls you can make, the headers that tell you where you stand, and what to do at a limit.

Source: https://developers.loyx.se/guides/rate-limits/

Limits protect the brand's members and keep the API fast for every till. They are counted **per API key**, in fixed one-minute windows.

| What | Limit per minute |
|---|---|
| Token requests (`POST /v1/auth/token`) | 30 per key, and 60 per calling IP address |
| Member lookups (`POST /v1/memberships/lookup`) | 300 |
| Reads, per family (members, products, stores, rewards) | 1,200 each |
| Writes, per family (sales, products, stores) | 600 each |

A normal store with several registers uses a small part of these. If you need more, for example to load a large catalog, contact us.

## Headers

Every response that counts against a limit tells you where you stand:

| Header | Meaning |
|---|---|
| `RateLimit-Limit` | The limit for this window. |
| `RateLimit-Remaining` | Calls left in this window. |
| `RateLimit-Reset` | Seconds until the window resets. |
| `Retry-After` | On a `429` only: seconds to wait before retrying. |

## When you hit a limit

You get `429` with the standard [error shape](/guides/errors/):

```json
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Too many requests."
  },
  "request_id": "..."
}
```

Wait at least `Retry-After` seconds, then retry. Do not retry in a tight loop: it only extends the wait.

The token endpoint fails safe: if it cannot check its limits it answers `503 token_endpoint_unavailable` rather than letting the request through. Retry with backoff.

## Good habits

- Cache the access token for its whole life.
- Look a member up once per sale, not per keystroke.
- Watch `RateLimit-Remaining` and slow down before you reach zero.
- Send sales from a queue at a steady pace. After an offline period, drain the queue gradually instead of all at once.
- Read the [changelog](/changelog/): limits may be raised, and are never lowered without notice.
