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

# Rate limits

> How many calls each key can make and how to react to the limit.

## Limits per key

The limits apply per API key, in a sliding window of 1 minute.

| Type | Calls | Which |
| - | - | - |
| Read | 600 per minute | `GET` (catalog, quota, list, detail and PDF), `GET /webhook-endpoints` and `GET /webhook-endpoints/{id}/deliveries` |
| Write | 60 per minute | `POST /uploads`, `POST /pretests`, `POST /webhook-endpoints`, `DELETE /webhook-endpoints/{id}` and `POST /webhook-endpoints/{id}/test` |

## Headers

Every authenticated response carries:

| Header | Meaning |
| - | - |
| `RateLimit-Limit` | The limit for the call type. |
| `RateLimit-Remaining` | Calls still left in the window. |
| `RateLimit-Reset` | Seconds until the window frees more calls. |
| `Retry-After` | Only on `429`: seconds to wait before trying again. |

Every response, success or error, carries `X-Request-Id`. Quote this value when you contact support.

## When you get a 429

There are two cases, both with `Retry-After`:

* [`rate_limited`](https://docs.myunite.ai/en/errors#rate_limited): the key exceeded the per-minute limit.
* [`concurrency_limit`](https://docs.myunite.ai/en/errors#concurrency_limit): the workspace already has too many pre-tests in progress (about 10 created through the API). Wait for one to finish.

Wait the `Retry-After` interval and try again. If it is a creation, reuse the same `Idempotency-Key` ([Idempotency](https://docs.myunite.ai/en/idempotency.md)).

```bash curl theme={null}
curl -i https://myunite.ai/api/v1/quota \
  -H "Authorization: Bearer $UNITE_API_KEY"
```

```javascript JavaScript theme={null}
async function getWithRetry(url, tries = 5) {
  for (let i = 0; i < tries; i++) {
    const res = await fetch(url, {
      headers: { Authorization: `Bearer ${process.env.UNITE_API_KEY}` },
    });
    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("Rate limit: retries exhausted");
}

const res = await getWithRetry("https://myunite.ai/api/v1/quota");
console.log(res.headers.get("RateLimit-Remaining"));
```

```python Python theme={null}
import os
import time
import requests

def get_with_retry(url, tries=5):
    for _ in range(tries):
        res = requests.get(
            url,
            headers={"Authorization": f"Bearer {os.environ['UNITE_API_KEY']}"},
        )
        if res.status_code != 429:
            return res
        time.sleep(int(res.headers.get("Retry-After", "1")))
    raise RuntimeError("Rate limit: retries exhausted")

res = get_with_retry("https://myunite.ai/api/v1/quota")
print(res.headers.get("RateLimit-Remaining"))
```

## Good practices

* Poll the status of a pre-test every 10 seconds or more, not in a tight loop.
* For many pre-tests, use the list (`GET /pretests`) instead of querying them one by one.
* Spread creations over time: the write limit is 60 per minute.


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