What an error looks like
A 4xx or 5xx status and an error object. code never changes for a given problem, so that's the thing to check. message is written for people and may be reworded. details carries specifics when there are any, and is null otherwise.
HTTP/1.1 402 Payment Required
{
"error": {
"code": "insufficient_credit",
"message": "This send needs 12 credits and the balance is 3.",
"details": { "needed": 12, "balance": 3 }
}
}Error codes
| Status | Code | What it means |
|---|---|---|
| 400 | invalid_json | The body is not valid JSON. |
| 401 | unauthorized | The API key is missing, mistyped or revoked. |
| 401 | key_expired | The API key has passed the expiry date it was given. Create a new key in the dashboard. |
| 402 | insufficient_credit | Not enough credit for the whole send. details.needed and details.balance say by how much; nothing was sent. |
| 403 | account_suspended | The account is suspended. Email support. |
| 403 | account_closed | The account is closed, so nothing can be sent or changed. |
| 403 | email_unconfirmed | The account owner has not yet typed in the code we emailed when the account was made. Live sends work once they have; test keys work throughout. |
| 403 | business_unverified | The account is on hold until we have proof of the business, so it cannot send. Reply to the email we sent the owner. |
| 403 | forbidden | Your role on the account cannot do this. Removing an opt-out, for example, needs an owner or admin. |
| 403 | ip_not_allowed | The request came from an address that is not on the API key's allowed list. Add the address to the key, or use another key. |
| 403 | insufficient_scope | The API key's scope does not cover this. A read key can only make GET requests; a send key can send, price and look up, and read or cancel only the texts and batches it sent. |
| 403 | test_key_live_data | Test keys can't read live data: contacts, lists, opt-outs, conversations, link clicks and live texts, or send to contacts or a list. See test keys. |
| 403 | test_mode_not_supported | Not possible with a test key. Test keys send test texts and set up test webhooks, and change nothing else: use a live key. |
| 404 | not_found | No such resource in your account. Another account's ids read as not found too. |
| 409 | idempotency_conflict | This Idempotency-Key was already used with a different request. Use a new key for a new request. |
| 409 | not_cancellable | The text, batch or campaign has already gone (or finished), so it can no longer be cancelled. |
| 409 | campaign_send | The batch is a campaign launch. Cancel the campaign with POST /campaigns/{id}/cancel instead, so its status changes too. |
| 409 | not_redactable | The text hasn't left yet, so its body can't be removed. Cancel it first. |
| 409 | not_editable | Only a draft campaign can be edited. |
| 409 | not_deletable | Only a draft campaign can be deleted. Cancel it instead. |
| 409 | already_launched | The campaign has already been sent or scheduled. |
| 409 | launching | The campaign is being sent right now. Try again in a moment. |
| 409 | contact_exists | Another contact already has that number. |
| 409 | sender_exists | You have already asked for that sender name. |
| 409 | sender_rejected | The sender name was not approved, so it needs no business details. |
| 409 | details_on_file | The business details for this sender name are already on file. |
| 409 | keyword_exists | You already have that keyword. |
| 409 | field_exists | You already have a custom field with that key. |
| 409 | in_use | A segment, reminder or recurring campaign still uses the custom field or segment. Change or stop those first; details.used_by names them. |
| 409 | series_ended | The recurring campaign has been stopped or has finished, so it cannot be changed, paused or resumed. Start a new one. |
| 409 | already_delivered | Your endpoint already accepted this webhook delivery, so it is not sent again. |
| 409 | webhook_disabled | The webhook is switched off. Turn it back on, then send the delivery again. |
| 413 | body_too_large | The body is over 1 MB. |
| 415 | unsupported_media_type | Send the body as application/json, with that Content-Type header. |
| 422 | validation_failed | The request isn't valid. details lists the fields and what's wrong with each. POST /messages also returns this when one send names more than 50,000 recipients, and POST /messages/bulk when it carries more than 1,000 messages. |
| 422 | no_valid_recipients | Every recipient was refused. details.rejected gives the reason for each. |
| 422 | body_too_long | The text is longer than 10 SMS parts. |
| 422 | sender_not_approved | The sender name is not approved for your account. |
| 422 | sender_not_supported | Sender names need the aggregator route, which your account is not set up to use. Send without a sender to go from a number. |
| 422 | signature_mismatch | To sign the sender name details, signature must repeat the representative's full name exactly. |
| 422 | evidence_required | The sender name details need a website, links or a file showing the business uses the name. |
| 422 | authorisation_required | The sender name belongs to a client, so add the brand owner's permission letter or contract. |
| 422 | link_not_allowed | The text links through a public link shortener such as bit.ly, tinyurl.com or qrco.de, which the networks block. details.domains names them. Use the full web address, or set track_links for a short link of our own. |
| 422 | from_not_available | The from number is not one your account can send from. GET /numbers/from lists the ones it can. |
| 422 | reason_required | Taking a number off the opt-out list needs a reason: say why the person can be texted again. |
| 422 | reserved_keyword | STOP, START and the other opt-out and opt-in words cannot be keywords. |
| 422 | invalid_url | A webhook URL is not a valid https URL, or contains a username or password. |
| 422 | unresolvable_host | A webhook URL's host could not be found. |
| 422 | private_address | A webhook URL points at a private or local network address. |
| 422 | too_many_webhooks | An account can have up to 10 webhook endpoints. |
| 429 | rate_limited | Too many requests. Wait for the number of seconds in the Retry-After header. |
| 500 | internal_error | Something went wrong on our side. Safe to retry with the same Idempotency-Key. |
Rejected numbers
A send with some bad numbers still goes to the good ones. The refused numbers come back in data.rejected, each with a reason, and none of them are charged. Only when every number is refused does the whole request fail, with no_valid_recipients.
| Reason | Why the number was refused |
|---|---|
invalid_number | Not a phone number we can read. |
unsupported_destination | A number outside the UK, Guernsey, Jersey and the Isle of Man. |
not_mobile | A UK landline or other non-mobile number. |
duplicate | The same number appeared more than once in the request; it gets one text. |
opted_out | The number is on your opt-out list. |
too_long | With merge fields filled in, the text for this person ran past 10 parts. |
empty_body | With merge fields filled in, the text for this person was empty. |
sim_number_limit | You picked one of our shared UK mobile numbers in from, and it can't take this text. They only text people who have texted them before, one part at a time, up to a daily number per account. Leave from out and the text goes from another number. |
blocked_link | With merge fields filled in, the text for this person linked through a public link shortener. Check that contact's fields. |
invalid_item | Bulk sends only: the item itself is malformed (no number, no body, a body over 1,600 characters). errors says what is wrong. |
Message error codes
A text that fails, comes back undelivered, is cancelled for a reason or is waiting to be tried again carries an error_code from this fixed list, in the API, in webhooks and in exports. Whatever the network or route reports is mapped to one of these, and anything we can't place more precisely is send_failed, so your code only ever has these to handle. error_message says more in words and may change.
A failed text never left us and its credits are back on your balance. An undelivered one left us and reached the network, so it is charged. A plain cancel, by you or through the dashboard, has no error code.
| Code | What it means | Status | Final | Refunded |
|---|---|---|---|---|
retrying | A route could not take the text on this attempt. It is back in the queue and will be tried again; the timeline says why. | queued or sending | No | Not yet |
not_approved | We checked the text (a new account's texts are checked before they go) and did not send it. | failed | Yes | Yes |
queue_expired | It waited in the queue for more than 24 hours without being sent, so it was stopped rather than sent late. | failed | Yes | Yes |
number_refused | The route refused the number: not a valid mobile, blocked, or one no route reaches. | failed | Yes | Yes |
sender_refused | The route did not accept the sender name or number the text was sent from. | failed | Yes | Yes |
content_refused | The route refused the text itself: empty, malformed, or longer once split than it was charged for. | failed | Yes | Yes |
send_unconfirmed | The route did not confirm whether it took the text, so we treated it as not sent and refunded it. It may still reach the phone. If a SIM gateway later reports it sent, the status moves to sent and the charge is taken again. | failed | Yes | Yes |
send_failed | It could not be sent after every attempt. This is also the code for any reason we cannot place more precisely. | failed | Yes | Yes |
undelivered | The text left us but the network could not deliver it. | undelivered | Yes | No |
unreachable | The phone was switched off or out of coverage until the network stopped trying. | undelivered | Yes | No |
network_rejected | The network refused the text, for example for a barred or blocked handset. | undelivered | Yes | No |
spam_filtered | A network's spam filter stopped the text. | undelivered | Yes | No |
opted_out | The number opted out before the text left, so it was cancelled. | cancelled | Yes | Yes |
expired_before_send | It had not been sent by the deadline set with expires_in, so it was cancelled. | cancelled | Yes | Yes |
number_erased | The number was erased from the account (POST /erasures) before the text left, so it was cancelled. | cancelled | Yes | Yes |
When to retry
Retry 429 after the Retry-After wait, and 500 or a dropped connection after a short pause. Send the same Idempotency-Key each time: if the first attempt did get through, you get its original answer back (with meta.replayed set to true) instead of a second send.
Don't retry other 4xx errors as they are; something in the request or the account needs changing first. The API reference lists which errors each endpoint can return.