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

# Rate limits and headers

> Request limits per version, the RateLimit headers and how to handle 429.

Limits are counted per minute (60-second window). When you exceed a limit the API returns `429` with a `Retry-After` header.

## Limits

### v1 (`/api/v1/crm`)

| Requests | Limit | Counted per |
| - | - | - |
| Writes: `POST`, `PUT` | 60 per minute | Account |
| Reads and cancellations: `GET`, `DELETE` | 300 per minute | Account |

Reads have their own budget, so polling does not use up the write limit. Writes that fail with a `4xx` status do not count toward the write limit. `DELETE` on a webhook endpoint uses the write limit. The public `track.js` script is not limited here.

### v2 (`/api/v2`)

| Requests | Limit | Counted per |
| - | - | - |
| All requests, before authentication | 120 per minute | IP address |
| Reads: `GET` | 300 per minute | Account |
| Writes: `POST`, `PATCH`, `DELETE` | 120 per minute | Account |

Both the IP limit and the account limit apply to a request.

### Client IP and `TRUST_PROXY`

The per-IP limit and the request logs use the client address that Express sees. Behind a load balancer or CDN that address is the proxy unless the server is told to trust the proxy's `X-Forwarded-For` header. Self-hosted deployments set the `TRUST_PROXY` environment variable:

| Value | Meaning |
| - | - |
| unset, empty, `false`, `0` | Off (default). The socket address is used. `X-Forwarded-For` is ignored, so a client cannot spoof its IP. |
| `true` | Trust every hop. Use only when the server is reachable only through your proxy. |
| a number, for example `1` | Trust that many proxy hops in front of the server. |
| `loopback`, a CIDR or a comma-separated list | Trust those addresses only. |

The v1 and v2 apps use the same value. Set it to the number of proxies in front of the API (usually `1`); otherwise all clients share one rate-limit bucket. This setting belongs to whoever operates the server; API clients do not set it.

## Response headers

Rate-limited endpoints return the standard headers on every response:

| Header | Meaning |
| - | - |
| `RateLimit-Limit` | Requests allowed in the window. |
| `RateLimit-Remaining` | Requests left in the current window. |
| `RateLimit-Reset` | Seconds until the window resets. |
| `Retry-After` | On `429` (and some `503`): seconds to wait before retrying. |

Other headers you may see:

| Header | Meaning |
| - | - |
| `X-Request-ID` | Id of this request. See [Request IDs](https://docs.oktivo.com/api-reference/request-ids.md). |
| `Idempotent-Replay` | `true` when the response is a stored replay. See [Idempotency](https://docs.oktivo.com/api-reference/idempotency.md). |

Browser clients can read all of these headers; they are exposed through CORS.

## 429 response

v2:

```json theme={null}
{
  "success": false,
  "requestId": "3f1c2c0e-6a41-4e0b-9f0e-1f2d6f1b8a77",
  "error": { "code": "RATE_LIMITED", "message": "Too many requests, please retry later" }
}
```

v1:

```json theme={null}
{
  "success": false,
  "message": "Rate limit exceeded. Try again in 45 seconds.",
  "code": "RATE_LIMITED",
  "requestId": "3f1c2c0e-6a41-4e0b-9f0e-1f2d6f1b8a77",
  "errorInfo": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Try again in 45 seconds."
  }
}
```

A separate `429` with code `SCHEDULE_LIMIT_REACHED` (v2) means too many scheduled calls are pending. It is not a request-rate limit.

## Handling limits

* Read `RateLimit-Remaining` and slow down before it reaches 0.
* On `429`, wait for `Retry-After` seconds, then retry. Add random jitter if many workers retry together.
* Use `POST /calls/bulk` for many calls instead of many single requests.
* Retry writes with an [Idempotency-Key](https://docs.oktivo.com/api-reference/idempotency.md) so a retry cannot duplicate work.

> [!NOTE]
>
> If the shared counter store is unavailable, requests are allowed through instead of being rejected.


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