When a request fails, the API returns a non-2xx HTTP status and a JSON body in one fixed shape. This page lists every code your account can receive from sending, verifying, your account and usage endpoints, with the cause and the fix for each. Use it to decide what your server does next and what your user sees.
The error envelope
Every error, from every endpoint, has the same three fields:
{
"error": {
"code": "phone_hourly_limit",
"message": "this number has had its hourly allowance",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}code: a short, stable identifier in lower case. Your code branches on this. Codes are never renamed.message: one sentence for a person to read. Log it, or show it to your team. Wording may improve over time, so do not parse it.request_id: an identifier for this API call, also sent in theX-Request-Idresponse header. Quote it when you contact support.
The request_id in an error is the id of the API call, not the OTP request id that a successful send returns. Store both in your logs.
All error codes
Sorted by HTTP status. The second column says which call can return the code.
| Status | Code | Call | Cause | Fix |
|---|---|---|---|---|
| 400 | invalid_code | verify | The code does not match the one sent. Each wrong try uses one of the five attempts. | Let the user try again. When the attempts are used up, send a new code. |
| 401 | unauthorized | any | The Authorization header is missing, or the key is wrong or revoked. | Send Authorization: Bearer followed by your key. Check the environment variable on the server; create a new key if it was revoked. |
| 402 | trial_used_up | send | Your free test messages are used up. | Ask to go live from Account in the dashboard. |
| 402 | insufficient_balance | send | Your live account’s wallet holds less than the price of one message. Nothing was sent or charged. | Recharge the wallet, then send again. |
| 403 | trial_restricted | send | In test mode, the number or country code is not the one you verified at sign-up. | Send to your own verified number, or go live. |
| 403 | account_suspended | send | Sending is paused on this account. | Contact support. |
| 403 | template_not_approved | send | The template is in our library but is not approved for your account yet. The message reads: request this template from the Templates page in your dashboard; it is available after our team approves it. | Request the template from the Templates page and send again once it shows Sendable now, or leave template out to use the default. |
| 404 | not_found | verify | The request_id is unknown to your account. | Pass the request_id from the send response exactly as returned. |
| 409 | already_verified | verify | This request was already verified successfully. | Treat the number as verified. Do not verify the same request twice. |
| 409 | not_pending | verify | The request has ended: it already expired, or it was locked after too many attempts. | Send a new code. |
| 409 | idempotency_key_reused | send | The Idempotency-Key was used before with a different request body. | Use a new key for each user action; reuse a key only to retry the identical request. |
| 409 | channel_not_enabled | send | The channel you asked for, such as whatsapp, is not switched on for your account. | Send with channel sms, or contact support to enable the channel. |
| 410 | expired | verify | More than five minutes passed since the code was sent. | Send a new code. |
| 422 | invalid_request | any | A field is missing or malformed, for example to is not 6 to 15 digits or code is not 4 to 10 characters. The message names the field. | Fix the field named in the message. |
| 422 | template_not_available | send | The template id is unknown, cannot be sent on your account, or was used with a channel other than sms. | Copy the id from the Templates page, or leave template out to use the default. |
| 429 | resend_cooldown | send | A code went to this number less than 30 seconds ago. | Wait, and show a resend timer in your app. |
| 429 | phone_hourly_limit | send | This number has had three codes in the last hour. | Ask the user to try later. Retrying now will not help. |
| 429 | phone_daily_limit | send | This number has had ten codes in the last 24 hours. | Ask the user to try tomorrow, or offer another way to sign in. |
| 429 | api_key_minute_limit | send | This API key sent 30 codes in the last minute. | Back off and retry, or spread traffic over time. |
| 429 | rate_limited | send | Your account reached its per-minute sending ceiling. | Back off and retry with exponential delays. Contact us if your normal traffic needs more. |
| 429 | test_limit | send | Your live account is switched to test mode and has used its daily free test messages. | Switch back to live in the dashboard, or wait until tomorrow (UTC). |
| 429 | too_many_attempts | verify | Five attempts were already used on this request; it is now locked. | Send a new code. |
| 503 | sending_unavailable | send | We could not send this message right now. Nothing was charged. | Retry after a short wait with the same Idempotency-Key, using exponential backoff. |
channel value other than sms or whatsapp is refused with HTTP 422 before anything is sent. Handle any 422 the same way: fix the request, do not retry it.Which errors each call can return
POST /v1/otp/send can return the authentication, test mode, account, balance, validation, idempotency, channel, template and limit errors, and 503 when a message cannot go out right now. The checks run in a fixed order: authentication, then the request body, then a replayed Idempotency-Key, then test mode rules, then rate limits, then your balance. A replay with a known Idempotency-Key returns the first response before any limit is checked.
POST /v1/otp/verify returns invalid_code, not_found, already_verified, not_pending, expired, too_many_attempts and invalid_request. Note the order of events on one request: wrong codes return 400 until five attempts are used, the next try returns 429 too_many_attempts, and every try after that returns 409 not_pending. Likewise an expired code returns 410 once, then 409 not_pending.
GET /v1/me and GET /v1/usage return 401 unauthorized for a bad key, and usage returns 422 invalid_request when the period is not in YYYY-MM form. See account and usage.
Handling errors well
- Show your user a message for the codes they can act on: a wrong code, an expired code, or a resend that came too soon. Everything else is for your logs.
- Never show the raw message to end users. Map codes to your own words, in their language.
- Retry only
sending_unavailable,rate_limitedandapi_key_minute_limit, with backoff. The rate limits page shows how. - Treat any other 5xx response like
sending_unavailable: wait, then retry with the same Idempotency-Key. - Alert your team on 401, 402 and 403. They mean a configuration or account problem, not a user mistake.
New to the API? Start with the quickstart. Errors you see only before going live are explained on test mode.
