Errors and rate limits
Base URL: https://chatsa.co/api/v1
Every error answers with an HTTP status and a JSON body with a stable, machine-readable code and a human message. Act on code; show or log message. The same code is in the X-Chat-Error header, so you can read it without parsing the body.
{ "code": "rate_limited", "message": "Too many requests for this key. Slow down.", "retry_after": 12 }
Some errors add fields that help you act, such as retry_after, window_open_until, template_status, meta_code, allowed_at or current. The older read endpoints (/conversations, /contacts, /analytics) answer errors as { "error": "…" }, except 403 workspace_key_required (GET /contacts with a key limited to some chatbots), which has the usual shape.
Common codes#
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_request | A field is missing or malformed; the message names it | Fix the request |
| 400 | idempotency_key_required | POST /whatsapp/messages or POST /whatsapp/voice came without its Idempotency-Key header (SMS and calls answer invalid_request) | Add one |
| 400 | invalid_url | A webhook URL isn't a public address, or a connected-app URL isn't a public https address | Use a public URL |
| 400 | invalid_return_url | A signup window's return_url isn't allowed for your app | Use a registered redirect URI |
| 400 | invalid_grant | A Connect code is unknown, expired, used, or doesn't match | Start the connection again |
| 401 | unauthorized | Missing, wrong or revoked key | Check the key; for a Connect token, offer to reconnect |
| 401 | invalid_client | Unknown client id or wrong client secret | Check your app's credentials |
| 403 | forbidden | The key lacks the scope or the chatbot, the workspace is inactive, or the plan doesn't include the feature | Use a key with the right scope; check the account |
| 403 | app_token_required | A /connect/* call with a key that isn't a Connect token or chatbot key | Use the connection's token |
| 403 | account_key_required | A partner account call with another kind of key | Use the account key |
| 403 | app_key_required | An erasure with a dashboard key | Use a chatbot key or the account key |
| 403 | provisioning_not_allowed | Your app doesn't have the account-creation tier (or it was turned off) | Apply |
| 403 | account_suspended | The partner account is suspended | Resume it with PATCH |
| 403 | sending_paused | This business's business-initiated messages are paused | Replies still work; see below |
| 404 | not_found | No such record, or not one this key may see | Check the id |
| 409 | in_progress | The same account is being created by another request | Retry in a moment |
| 409 | idempotency_in_progress | A request with this idempotency key is still running | Retry in a moment with the same key |
| 409 | idempotency_key_reused | The same key was used for a different text or call | Use a new key for a new send |
| 409 | window_closed | WhatsApp's 24-hour window is closed | Send an approved template |
| 409 | opted_out | The person opted out | Don't send |
| 409 | not_connected, needs_reconnect | SMS or calls: Twilio credentials missing or refused (on /whatsapp/display-name, not_connected means the number isn't connected) | Save new credentials |
| 409 | chatbot_limit | The account has no room for another number | Remove one or ask ChatSa |
| 413 | media_too_large | A file is over the limit for its type | Send a smaller file |
| 422 | invalid_number, undeliverable | Not a valid number, or not on WhatsApp | Check the number |
| 422 | template_not_approved, invalid_template_params | The template isn't approved, or its values don't fit | Check GET /whatsapp/templates |
| 422 | media_unreachable, media_type_not_allowed | ChatSa couldn't fetch the file, or the type isn't allowed | Use a public https link of an allowed type |
| 422 | no_consent | SMS: no consent on record for this customer and number | Record consent, or wait for them to text first |
| 422 | quiet_hours | SMS or calls: outside 8 am–9 pm where the customer is | Wait until allowed_at |
| 422 | twilio_refused | Twilio refused the text or call | See error_code (SMS) or twilio_code (calls) |
| 429 | rate_limited | Too many requests | Wait Retry-After seconds |
| 429 | twilio_rate_limited | Twilio is limiting this account | Retry later with the same idempotency key |
| 429 | daily_cap_reached | This business reached its daily cap of business-initiated messages | Wait until resets_at (Retry-After); replies still work |
| 500 | server_error, save_failed, erasure_failed | Something failed on ChatSa's side; nothing half-done is left | Retry with backoff (the same idempotency key) |
| 502 | send_failed | WhatsApp refused the message or couldn't be reached | See meta_code; retry later |
| 502 | twilio_unavailable | Twilio couldn't be reached | Retry later |
| 503 | not_connected, unavailable | The WhatsApp number isn't connected (or its token expired), or a dependency is down | Reconnect the number; retry later |
| 503 | sms_disabled, voice_disabled | SMS or calls aren't switched on in ChatSa yet | Ask ChatSa |
The page for each API lists its own codes: WhatsApp, Connect, partner API, SMS, calls.
Per-business sending limits#
A business that sends spam has its business-initiated messages paused, while its replies keep working. See the account.safety event and the errors 403 sending_paused and 429 daily_cap_reached, explained in Per-business sending limits.
Rate limits#
| Surface | Limit |
|---|---|
WhatsApp API (/whatsapp/*) | 60 sends and other writes, 600 reads a minute, per key |
SMS and calls (/sms/*, /voice/*) | 60 writes, 600 reads a minute, per key; test texts 5 an hour per workspace |
Connect token exchange (/connect/token) | 60 a minute per client id |
Connect setup calls (/connect/*) | 30 a minute per token |
| Partner accounts (client credentials) | 60 a minute per app |
| Partner account calls (account key), erasures | 30 a minute per key |
Past a per-minute limit ChatSa answers 429 rate_limited with a Retry-After header (seconds) and retry_after in the body. Wait at least that long. (The hourly test-text limit answers 429 rate_limited without them.) WhatsApp and Twilio have their own limits on top. When WhatsApp throttles a number, the send answers 429 rate_limited with meta_code and Retry-After: 30; other WhatsApp limits (for example its daily limit on new conversations per business) arrive as 502 send_failed with meta_code; Twilio's arrive as 429 twilio_rate_limited.
Idempotency#
Every call that sends something takes an idempotency key, so a retry after a timeout never sends twice:
| Call | Key | Kept |
|---|---|---|
POST /whatsapp/messages, POST /whatsapp/voice | Idempotency-Key header, required, up to 100 characters | 24 hours, per API key |
POST /partner/erasures | Idempotency-Key header, optional, up to 100 characters | 24 hours, per key |
POST /sms/messages, POST /voice/calls | idempotency_key in the body (or the header), required, 1–100 of A-Z a-z 0-9 . _ : - | For good, per workspace |
- The same key again answers the first result without doing the work twice. Replays of
POST /whatsapp/messagescarry the headerIdempotent-Replayed: true; SMS and calls answer200with the record the key made. - A refusal before anything was sent (a bad request, a closed window, an opt-out, quiet hours…) frees the key, so you may retry with the same key once you've fixed the cause. Two exceptions:
POST /whatsapp/voicereplays its refusals too (only409,429and5xxanswers free its key), and a text or call that Twilio refused keeps its key. - A send whose outcome is unknown (a timeout towards WhatsApp or Twilio) keeps the key, so retrying never sends twice. WhatsApp marks it
delivery_unknown: true; SMS answers202withstatus: "unknown", and a call202withstatus: "pending". - A key still being processed answers
409 idempotency_in_progress: wait and retry with the same key.
Retrying well#
- Retry
429,500,502and503with exponential backoff and jitter (for example 1 s, 2 s, 4 s… up to a minute), always with the same idempotency key. - Don't retry
4xxother than409 idempotency_in_progress,409 in_progressand429without changing the request. - ChatSa already retries passing WhatsApp failures before answering, so a fast retry loop on top only adds load.
- Webhooks are retried by ChatSa for you: answer 2xx quickly and de-duplicate on
X-ChatSA-Delivery(Webhooks).