Errors, rate limits and retries
What an API error looks like, every status and error code, how many requests each plan may make a minute, and how to retry without doing anything twice.
Before you start
- Log the X-Request-Id of every answer. It is the fastest way for us to find a request when you ask.
What does an error look like?
Every error is JSON with a detail (a sentence to show or log; for 422 it may be a list of the fields at fault), a code to branch on, and the request_id. Every answer, error or not, carries the same id in its X-Request-Id header, and the request is in your Developers page logs under it: quote it when you ask us about a request.
{
"detail": "This token does not have the 'contacts:write' scope.",
"code": "forbidden",
"request_id": "5f2c9a1e7b3d4c6a8e0f"
}Which status codes and error codes can I get?
| Status | code | When |
|---|---|---|
| 400 | bad_request | The request cannot be read: a malformed body or header. |
| 401 | unauthorized | The token is missing, unknown or revoked, or its workspace was deleted. |
| 402 | plan_required | The plan does not include API access (the token is paused, not revoked), or has no calls left for this voice tier. |
| 403 | forbidden | The token lacks the endpoint's scope, is a sandbox token, the workspace is suspended, the address is not on the IP allowlist, or the person cannot be called or messaged (Do-Not-Call, no consent, outside the calling window). |
| 404 | not_found | The thing named is not there, or is switched off. |
| 405 | method_not_allowed | The path exists, with another method. |
| 409 | conflict | It cannot happen now: a calls-at-once limit, calling hours, a paused agent. Also idempotency_in_progress, while the first request with the same Idempotency-Key is still running. |
| 413 | too_large | The body or file is bigger than the endpoint takes. |
| 422 | invalid_request | A field is missing or in the wrong form; detail lists them. Also idempotency_key_reused, when a key comes back with a different body. |
| 428 | idempotency_key_required | Sending a message needs an Idempotency-Key header. Nothing was sent. |
| 429 | rate_limited | More requests this minute than the plan allows. Wait the seconds in Retry-After. |
| 500 | server_error | Our fault. Not kept for idempotency, so the same key can be tried again. |
| 502 | upstream_unavailable | Something the request depends on did not answer, so nothing was done. Try again. |
| 503 | unavailable | The service is briefly unavailable. Try again shortly. |
Each endpoint in the API reference lists its own reasons for each status.
How many requests can I make?
Each token may make a set number of requests a minute, across every endpoint, by plan. The next one answers 429 with a Retry-After header in seconds. A plan without its own figure gets 60 requests a minute. Some endpoints have a limit of their own as well, stated on the endpoint.
| Plan | Requests a minute |
|---|---|
| Starter | 60 |
| Growth | 60 |
| Professional | 120 |
| Enterprise | 300 |
How do I retry without calling someone twice?
Send an Idempotency-Key header, any unique text up to 255 characters such as a UUID, with every write (every post, patch and delete). The same key again within 24 hours gets the first answer back, with Idempotent-Replayed: true, and nothing is done twice: no second call, no second contact. The same key with a different body answers 422; while the first is still running, 409. An answer of 500 or above is not kept, so the key can be tried again. With the scope messages:send the header is required: without it the request answers 428 and nothing is sent.
How do I page through a list?
Lists answer {data, next_cursor}. Pass next_cursor as cursor for the next page; it is null on the last page.
What should my code retry?
Retry 429 after the seconds in Retry-After, and 500, 502 and 503 after a short wait, with the same Idempotency-Key, so nothing is done twice. Do not retry 400, 401, 402, 403, 404 or 422 unchanged: the same request gets the same answer. A 409 may succeed later, once the reason in its detail has passed.
Costs and what to watch
- A write sent again without an Idempotency-Key is a new request: a retried call without one can ring the person twice.
Questions, answered.
What is the AI Call Studio API rate limit?
Read next
Quickstart: your first AI call from code in 5 minutes
Make an API key, find your agent, place one AI call to your own number and read its outcome, in curl, Node.js, Python or PHP.
Read more →Webhooks: every event, with a sample
Every event AI Call Studio can send your server, with a sample of each, the headers, how to check the signature, and what happens when a delivery fails.
Read more →Use cases
Recipes with every step and the code to copy: form to call, EMI reminders, CRM leads, WhatsApp follow-ups.
Read more →