# Rate limits

> 120 calls a minute per key, and a shared 20 a minute for the calls that read, fill and send.

Limits are per API key and count calls in a rolling minute. A call with a missing or wrong key is refused before it is counted, so nobody can use up your budget by guessing keys.

| Budget | Limit | Counts |
| --- | --- | --- |
| Standard | 120 calls a minute per key | Every call to the REST API and the MCP server. |
| Shared pool | 20 calls a minute per key, shared | The calls that read a form, fill it or send email, listed below. |

The shared pool is one budget for all of these together, not 20 each:

- `POST /api/v1/fill`
- `POST /api/v1/documents/{id}/detect`
- `POST /api/v1/documents/{id}/fill`
- `POST /api/v1/documents/{id}/send`
- `POST /api/v1/templates/{id}/create-document`
- `POST /api/v1/templates/{id}/send`
- `POST /api/v1/templates/{id}/bulk`
- `POST /api/v1/bulk-batches/{id}/retry-failed`
- `PATCH /api/v1/bulk-batches/{id}/rows/{row}`

On the MCP server, these tools use the same shared pool: `detect_fields`, `fill_document`, `fill_form_oneshot`, `send_envelope`, `create_from_template`, `send_template`, `send_template_bulk` and `fix_bulk_row`. Every other tool uses the standard budget.

Send to many has one more limit: a key can start at most 10 batches a minute, and a workspace can have at most 2 batches sending at once (`409 too_many_running`).

## When you hit a limit

The reply is `429` with a `Retry-After` header, in seconds:

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 17

{ "success": false, "error": "rate limit exceeded" }
```

Wait that many seconds, then send the same request again with the same `Idempotency-Key`. The MCP server answers `429` the same way, with JSON-RPC error `-32029`.

**Node**

```js
async function withRetry(call) {
  for (let attempt = 0; attempt < 5; attempt++) {
    const res = await call();
    if (res.status !== 429) return res;
    const wait = Number(res.headers.get("retry-after") ?? "1");
    await new Promise((r) => setTimeout(r, wait * 1000));
  }
  throw new Error("still rate limited after 5 tries");
}
```

**Python**

```python
import time

def with_retry(call):
    for _ in range(5):
        res = call()
        if res.status_code != 429:
            return res
        time.sleep(int(res.headers.get("Retry-After", "1")))
    raise RuntimeError("still rate limited after 5 tries")
```

## Staying under the limit

- Fill many documents one after another rather than all at once.
- To send one template to many people, use [send to many](https://dev.appliflo.com/guides/send-to-many): one call queues up to 500 envelopes, sent for you at a steady pace.
- Poll an envelope or a batch every few seconds at most.
