Skip to Content
Sendable Docs

Error Handling

HTTP status codes, error bodies, and which Sendable API errors to retry.

HTTP Status Codes

CodeMeaningRetry?
400Invalid request: body validation failed, bad cursor, bad phone number or jidNo, fix the request
401Missing, invalid, disabled, or expired API keyNo
403The key may not call this route: missing permission (insufficient_scope), or a session key on an account route. Also when WhatsApp refuses (not a group admin)No
404Session, chat, message, group, or webhook not foundNo
409Conflict, for example an Idempotency-Key whose first request is still runningYes, after Retry-After
410Gone, for example an expired inviteNo
422Idempotency-Key reused with a different request bodyNo, use a new key
429Rate limited (per API key or by the session send policy)Yes, after Retry-After
500Unexpected server errorYes, with backoff
502WhatsApp returned an errorYes, with backoff
503WhatsApp session not connected, or the send queue is unavailableYes, with backoff

Error Bodies

JSON errors have an error field with a stable code and, usually, a message:

{ "error": "rate_limited", "message": "api key rate limit exceeded", "retryAfter": 1260 }
errorStatusMeaning
Validation failed400The body or query failed validation. issues lists each field: [{ "path": "/chatId", "message": "Expected string" }]
insufficient_scope403The API key's permissions do not include required (for example message:write)
rate_limited429The API key used up its request limit. retryAfter is in seconds
idempotency_key_in_progress409The first request with this Idempotency-Key is still running
idempotency_key_mismatch422The Idempotency-Key was used before with a different body
internal_error500Unexpected server error

Other errors are returned as a plain-text message (Content-Type: text/plain), for example 401 invalid api key, 404 chat not found, or 503 whatsapp socket not connected. Read the body as text when it is not JSON.

The OpenAPI document describes these as the shared ErrorResponse schema.

Retry Strategy

  • Honour Retry-After (seconds) on 409 and 429.
  • Retry 500, 502, and 503 with exponential backoff and jitter.
  • Send an Idempotency-Key with POST /v1/message/send so a retry never sends the same message twice.
  • The SDK retries 429, 503, and network errors for you when you set maxRetries.
async function sendWithRetry(body: unknown, idempotencyKey: string, maxRetries = 3) {
  for (let attempt = 0; ; attempt++) {
    const res = await fetch('https://api.sendable.dev/v1/message/send', {
      method: 'POST',
      headers: {
        'x-api-key': process.env.SENDABLE_API_KEY!,
        'content-type': 'application/json',
        'Idempotency-Key': idempotencyKey,
      },
      body: JSON.stringify(body),
    })
    const retryable = [409, 429, 500, 502, 503].includes(res.status)
    if (!retryable || attempt >= maxRetries) return res
    const retryAfter = Number(res.headers.get('retry-after'))
    const delayMs = retryAfter > 0 ? retryAfter * 1000 : 2 ** attempt * 1000
    await new Promise((r) => setTimeout(r, delayMs + Math.random() * 250))
  }
}

On this page