Skip to content
CaptiFi Connect

Developer docs

Errors and error codes

Every error comes back in the same shape with a stable code, so your code can branch on the code and show people the message.

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

StatusCodeWhat it means
400invalid_jsonThe body is not valid JSON.
401unauthorizedThe API key is missing, mistyped or revoked.
401key_expiredThe API key has passed the expiry date it was given. Create a new key in the dashboard.
402insufficient_creditNot enough credit for the whole send. details.needed and details.balance say by how much; nothing was sent.
403account_suspendedThe account is suspended. Email support.
403account_closedThe account is closed, so nothing can be sent or changed.
403email_unconfirmedThe 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.
403business_unverifiedThe account is on hold until we have proof of the business, so it cannot send. Reply to the email we sent the owner.
403forbiddenYour role on the account cannot do this. Removing an opt-out, for example, needs an owner or admin.
403ip_not_allowedThe 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.
403insufficient_scopeThe 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.
403test_key_live_dataTest 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.
403test_mode_not_supportedNot possible with a test key. Test keys send test texts and set up test webhooks, and change nothing else: use a live key.
404not_foundNo such resource in your account. Another account's ids read as not found too.
409idempotency_conflictThis Idempotency-Key was already used with a different request. Use a new key for a new request.
409not_cancellableThe text, batch or campaign has already gone (or finished), so it can no longer be cancelled.
409campaign_sendThe batch is a campaign launch. Cancel the campaign with POST /campaigns/{id}/cancel instead, so its status changes too.
409not_redactableThe text hasn't left yet, so its body can't be removed. Cancel it first.
409not_editableOnly a draft campaign can be edited.
409not_deletableOnly a draft campaign can be deleted. Cancel it instead.
409already_launchedThe campaign has already been sent or scheduled.
409launchingThe campaign is being sent right now. Try again in a moment.
409contact_existsAnother contact already has that number.
409sender_existsYou have already asked for that sender name.
409sender_rejectedThe sender name was not approved, so it needs no business details.
409details_on_fileThe business details for this sender name are already on file.
409keyword_existsYou already have that keyword.
409field_existsYou already have a custom field with that key.
409in_useA segment, reminder or recurring campaign still uses the custom field or segment. Change or stop those first; details.used_by names them.
409series_endedThe recurring campaign has been stopped or has finished, so it cannot be changed, paused or resumed. Start a new one.
409already_deliveredYour endpoint already accepted this webhook delivery, so it is not sent again.
409webhook_disabledThe webhook is switched off. Turn it back on, then send the delivery again.
413body_too_largeThe body is over 1 MB.
415unsupported_media_typeSend the body as application/json, with that Content-Type header.
422validation_failedThe 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.
422no_valid_recipientsEvery recipient was refused. details.rejected gives the reason for each.
422body_too_longThe text is longer than 10 SMS parts.
422sender_not_approvedThe sender name is not approved for your account.
422sender_not_supportedSender names need the aggregator route, which your account is not set up to use. Send without a sender to go from a number.
422signature_mismatchTo sign the sender name details, signature must repeat the representative's full name exactly.
422evidence_requiredThe sender name details need a website, links or a file showing the business uses the name.
422authorisation_requiredThe sender name belongs to a client, so add the brand owner's permission letter or contract.
422link_not_allowedThe 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.
422from_not_availableThe from number is not one your account can send from. GET /numbers/from lists the ones it can.
422reason_requiredTaking a number off the opt-out list needs a reason: say why the person can be texted again.
422reserved_keywordSTOP, START and the other opt-out and opt-in words cannot be keywords.
422invalid_urlA webhook URL is not a valid https URL, or contains a username or password.
422unresolvable_hostA webhook URL's host could not be found.
422private_addressA webhook URL points at a private or local network address.
422too_many_webhooksAn account can have up to 10 webhook endpoints.
429rate_limitedToo many requests. Wait for the number of seconds in the Retry-After header.
500internal_errorSomething 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.

ReasonWhy the number was refused
invalid_numberNot a phone number we can read.
unsupported_destinationA number outside the UK, Guernsey, Jersey and the Isle of Man.
not_mobileA UK landline or other non-mobile number.
duplicateThe same number appeared more than once in the request; it gets one text.
opted_outThe number is on your opt-out list.
too_longWith merge fields filled in, the text for this person ran past 10 parts.
empty_bodyWith merge fields filled in, the text for this person was empty.
sim_number_limitYou 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_linkWith merge fields filled in, the text for this person linked through a public link shortener. Check that contact's fields.
invalid_itemBulk 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.

CodeWhat it meansStatusFinalRefunded
retryingA 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 sendingNoNot yet
not_approvedWe checked the text (a new account's texts are checked before they go) and did not send it.failedYesYes
queue_expiredIt waited in the queue for more than 24 hours without being sent, so it was stopped rather than sent late.failedYesYes
number_refusedThe route refused the number: not a valid mobile, blocked, or one no route reaches.failedYesYes
sender_refusedThe route did not accept the sender name or number the text was sent from.failedYesYes
content_refusedThe route refused the text itself: empty, malformed, or longer once split than it was charged for.failedYesYes
send_unconfirmedThe 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.failedYesYes
send_failedIt could not be sent after every attempt. This is also the code for any reason we cannot place more precisely.failedYesYes
undeliveredThe text left us but the network could not deliver it.undeliveredYesNo
unreachableThe phone was switched off or out of coverage until the network stopped trying.undeliveredYesNo
network_rejectedThe network refused the text, for example for a barred or blocked handset.undeliveredYesNo
spam_filteredA network's spam filter stopped the text.undeliveredYesNo
opted_outThe number opted out before the text left, so it was cancelled.cancelledYesYes
expired_before_sendIt had not been sent by the deadline set with expires_in, so it was cancelled.cancelledYesYes
number_erasedThe number was erased from the account (POST /erasures) before the text left, so it was cancelled.cancelledYesYes

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.