Contents

Errors, retries & idempotency

Error codes and how to retry safely.

Error format

400 Bad Request
{
  "success": false,
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Request validation failed",
    "details": [{ "field": "mobile", "message": "mobile must be longer than or equal to 8 characters" }]
  },
  "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
}
  • Branch on error.code. Codes are never renamed or reused; new codes may be added, so fall back to the HTTP status.
  • message is for humans and may change. Do not show it to end users verbatim or parse it.
  • details[].field points at the offending input, e.g. variables.order.

Error codes

Authentication and access

CodeHTTPMeaningRetry
AUTHENTICATION_REQUIRED401No API key was sent.Fix the request or configuration first
API_KEY_INVALID401The key is malformed or unknown.Fix the request or configuration first
API_KEY_REVOKED401The key was revoked.Fix the request or configuration first
API_KEY_EXPIRED401The key passed its expiry date.Fix the request or configuration first
INSUFFICIENT_SCOPE403The key lacks the scope named in details.Fix the request or configuration first
IP_NOT_ALLOWED403The calling IP is not on the key allow-list.Fix the request or configuration first
PROJECT_INACTIVE403The project is archived.Fix the request or configuration first
PROJECT_SUSPENDED403SMS21 suspended the project; contact support.Fix the request or configuration first
API_KEY_SUSPENDED403SMS21 suspended the key; contact support.Fix the request or configuration first
COMPANY_SUSPENDED403The company is suspended by SMS21.Fix the request or configuration first

Request

CodeHTTPMeaningRetry
VALIDATION_FAILED400A field is missing, malformed or unknown; see details.Fix the request or configuration first
INVALID_RECIPIENT400Not a valid mobile number in international format.Fix the request or configuration first
IDEMPOTENCY_KEY_INVALID400Idempotency-Key is not 1-128 of A-Z a-z 0-9 . _ : -Fix the request or configuration first
IDEMPOTENCY_KEY_REUSED409The key was already used with a different body.Do not retry
NOT_FOUND404No such resource in this project.Do not retry
PAYLOAD_TOO_LARGE413The body exceeds the size limit.Fix the request or configuration first
BULK_TOO_MANY_RECIPIENTS400A campaign holds more recipients than SMS21 accepts; split the list.Fix the request or configuration first
BATCH_NOT_CANCELLABLE409The campaign already finished, failed or was cancelled.Do not retry
RECIPIENT_SUPPRESSED400The number is on your opt-out list.Fix the request or configuration first
UNSUPPORTED_MEDIA_TYPE415Send Content-Type: application/json.Fix the request or configuration first

Content, DLT and templates

CodeHTTPMeaningRetry
TEMPLATE_REQUIRED400Live SMS to this country needs an approved DLT template.Fix the request or configuration first
TEMPLATE_VARIABLES_INVALID400Variables are missing, unexpected or too long.Fix the request or configuration first
TEMPLATE_CATEGORY_NOT_ALLOWED400The template category does not fit this message type.Fix the request or configuration first
MESSAGE_TOO_LONG400More than 10 SMS segments.Fix the request or configuration first
OTP_TEMPLATE_INVALID400The OTP template has no {{otp}} variable.Fix the request or configuration first
WHATSAPP_TEMPLATE_INVALID400Wrong WhatsApp template for this endpoint.Fix the request or configuration first
TEMPLATE_NOT_APPROVED409The template is not approved (yet).Fix the request or configuration first
DLT_ENTITY_NOT_APPROVED409The DLT entity is not approved.Fix the request or configuration first
SENDER_ID_NOT_APPROVED409The sender ID (header) is not approved.Fix the request or configuration first

OTP

CodeHTTPMeaningRetry
OTP_INVALID400Wrong code; details give the attempts left.Do not retry
OTP_EXPIRED410Expired, or superseded by a newer OTP.Do not retry
OTP_ALREADY_VERIFIED409The request was already verified once.Do not retry
OTP_ATTEMPTS_EXCEEDED429Locked after too many wrong codes.Do not retry
OTP_RESEND_COOLDOWN429Too soon to send another OTP to this number.Retry after Retry-After / later
DESTINATION_NOT_ALLOWED400OTPs are not enabled for this country.Do not retry

Billing and platform controls

CodeHTTPMeaningRetry
INSUFFICIENT_BALANCE402Live traffic: the wallet cannot cover the message.Fix the request or configuration first
WALLET_SUSPENDED403Live sending is suspended for the wallet.Fix the request or configuration first
PRICING_NOT_CONFIGURED409No price applies; contact SMS21.Fix the request or configuration first
DESTINATION_BLOCKED403The destination is blocked by SMS21 risk controls.Do not retry
DAILY_LIMIT_EXCEEDED429The company daily live message limit is reached.Retry after Retry-After / later
SENDING_PAUSED503SMS21 paused sending on this channel.Retry after Retry-After / later

Transient

CodeHTTPMeaningRetry
RATE_LIMITED429Request rate limit; wait Retry-After seconds.Retry with the same Idempotency-Key
SERVICE_UNAVAILABLE503A dependency is temporarily unavailable.Retry with the same Idempotency-Key
INTERNAL_ERROR500Unexpected error; quote the requestId to support.Retry with the same Idempotency-Key

Retrying safely

FailureSends (OTP send, SMS, WhatsApp)OTP verifyReads
Network error or timeoutRetry with the same Idempotency-KeyDo not retryRetry
500, 502, 503, 504Retry with the same Idempotency-Key (not SENDING_PAUSED)Do not retryRetry
429 RATE_LIMITEDWait Retry-After, then retryWait Retry-After, then retryWait, then retry
Other 4xxFix the requestShow the outcomeFix the request

Use exponential backoff with jitter (for example 0.5 s, 1 s, 2 s… up to 8 s) and a small retry budget.

Idempotency keys

  • Header Idempotency-Key: 1–128 characters of A–Z a–z 0–9 . _ : -.
  • Accepted by POST /otp/send, /sms/send, /whatsapp/send and /whatsapp/template; scoped to the project.
  • Same key and same body → the original result, with Idempotent-Replayed: true. Nothing is sent or charged again.
  • Same key, different body → 409 IDEMPOTENCY_KEY_REUSED.
  • Derive keys from your own IDs (trip2all:booking:88121:confirmation) so they survive process restarts.

Why OTP verification is different

Verification cannot be made idempotent without weakening it: each attempt counts, and a code works once. If a verify call times out, ask the user to request a new code rather than retrying.