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#

StatusCodeMeaningWhat to do
400invalid_requestA field is missing or malformed; the message names itFix the request
400idempotency_key_requiredPOST /whatsapp/messages or POST /whatsapp/voice came without its Idempotency-Key header (SMS and calls answer invalid_request)Add one
400invalid_urlA webhook URL isn't a public address, or a connected-app URL isn't a public https addressUse a public URL
400invalid_return_urlA signup window's return_url isn't allowed for your appUse a registered redirect URI
400invalid_grantA Connect code is unknown, expired, used, or doesn't matchStart the connection again
401unauthorizedMissing, wrong or revoked keyCheck the key; for a Connect token, offer to reconnect
401invalid_clientUnknown client id or wrong client secretCheck your app's credentials
403forbiddenThe key lacks the scope or the chatbot, the workspace is inactive, or the plan doesn't include the featureUse a key with the right scope; check the account
403app_token_requiredA /connect/* call with a key that isn't a Connect token or chatbot keyUse the connection's token
403account_key_requiredA partner account call with another kind of keyUse the account key
403app_key_requiredAn erasure with a dashboard keyUse a chatbot key or the account key
403provisioning_not_allowedYour app doesn't have the account-creation tier (or it was turned off)Apply
403account_suspendedThe partner account is suspendedResume it with PATCH
403sending_pausedThis business's business-initiated messages are pausedReplies still work; see below
404not_foundNo such record, or not one this key may seeCheck the id
409in_progressThe same account is being created by another requestRetry in a moment
409idempotency_in_progressA request with this idempotency key is still runningRetry in a moment with the same key
409idempotency_key_reusedThe same key was used for a different text or callUse a new key for a new send
409window_closedWhatsApp's 24-hour window is closedSend an approved template
409opted_outThe person opted outDon't send
409not_connected, needs_reconnectSMS or calls: Twilio credentials missing or refused (on /whatsapp/display-name, not_connected means the number isn't connected)Save new credentials
409chatbot_limitThe account has no room for another numberRemove one or ask ChatSa
413media_too_largeA file is over the limit for its typeSend a smaller file
422invalid_number, undeliverableNot a valid number, or not on WhatsAppCheck the number
422template_not_approved, invalid_template_paramsThe template isn't approved, or its values don't fitCheck GET /whatsapp/templates
422media_unreachable, media_type_not_allowedChatSa couldn't fetch the file, or the type isn't allowedUse a public https link of an allowed type
422no_consentSMS: no consent on record for this customer and numberRecord consent, or wait for them to text first
422quiet_hoursSMS or calls: outside 8 am–9 pm where the customer isWait until allowed_at
422twilio_refusedTwilio refused the text or callSee error_code (SMS) or twilio_code (calls)
429rate_limitedToo many requestsWait Retry-After seconds
429twilio_rate_limitedTwilio is limiting this accountRetry later with the same idempotency key
429daily_cap_reachedThis business reached its daily cap of business-initiated messagesWait until resets_at (Retry-After); replies still work
500server_error, save_failed, erasure_failedSomething failed on ChatSa's side; nothing half-done is leftRetry with backoff (the same idempotency key)
502send_failedWhatsApp refused the message or couldn't be reachedSee meta_code; retry later
502twilio_unavailableTwilio couldn't be reachedRetry later
503not_connected, unavailableThe WhatsApp number isn't connected (or its token expired), or a dependency is downReconnect the number; retry later
503sms_disabled, voice_disabledSMS or calls aren't switched on in ChatSa yetAsk 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#

SurfaceLimit
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), erasures30 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:

CallKeyKept
POST /whatsapp/messages, POST /whatsapp/voiceIdempotency-Key header, required, up to 100 characters24 hours, per API key
POST /partner/erasuresIdempotency-Key header, optional, up to 100 characters24 hours, per key
POST /sms/messages, POST /voice/callsidempotency_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/messages carry the header Idempotent-Replayed: true; SMS and calls answer 200 with 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/voice replays its refusals too (only 409, 429 and 5xx answers 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 answers 202 with status: "unknown", and a call 202 with status: "pending".
  • A key still being processed answers 409 idempotency_in_progress: wait and retry with the same key.

Retrying well#

  • Retry 429, 500, 502 and 503 with 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 4xx other than 409 idempotency_in_progress, 409 in_progress and 429 without 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).