Errors and limits
The shape of an error
Every error answers with a code and a description:
{
"error": "invalid_recipient",
"error_description": "Could not determine a country for \"12345\"."
}Switch on error. The description is written for people, and its wording can change.
A request that fails validation answers 400 with the code validation_, and lists the problems by field in errors. A problem with the whole body is under _:
{
"error": "validation_error",
"error_description": "The request isn't valid. Fix the fields listed in errors, then try again.",
"errors": {
"to": ["Too small: expected array to have >=1 items"]
}
}An unexpected fault on our side answers 500 with the code internal_. The request may still have taken effect, so check before you try again:
{
"error": "internal_error",
"error_description": "The request failed on our side. It may still have taken effect, so check what it was meant to change before you try again."
}When we're busy, a GET request answers 503 with the code service_ and a Retry-After header. Wait that many seconds, then send it again; repeating a GET is safe. A request that changes something gets the 500 above instead, because part of it may already have happened.
Error codes
Each table lists the codes an API key can get, by what the request was doing.
Every request
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | validation_ | A field is missing, has the wrong type, or is out of range. errors names each field. | Fix the fields listed in errors. |
| 400 | invalid_ | The Idempotency-Key header is empty or longer than 255 characters. | Send a key of 1 to 255 characters. |
| 401 | invalid_ | The key is wrong, disabled, expired or revoked. | Check the key on the API keys screen. |
| 401 | invalid_ | The request had no API key, or the Authorization header didn't hold one. | Send your key as Authorization: Bearer <your key>. |
| 403 | insufficient_ | The key doesn't have the permission this endpoint needs. | Add the permission named in the description, or use another key. |
| 403 | api_ | Only a person signed in to the portal can use this endpoint. | Use the portal. |
| 403 | api_ | This endpoint only answers an API key. | Call it with your key, not a portal session. |
| 403 | not_ | A filter reads data the key isn't permitted to read. The description names the permissions it reads. A person signed in to the portal who lacks the permission gets the same code. | Use a key that holds the permissions named in the description. |
| 404 | not_ | The organization, message or other item in the path doesn't exist for your key. | Check the account ID and the IDs in the path. |
| 409 | idempotency_ | A request with this Idempotency-Key is still running, or never finished. | See Retrying safely. |
| 422 | idempotency_ | This Idempotency-Key was already used with a different request. | Use a new key for a new request. |
| 429 | rate_ | The key sent more requests in a minute than its limit, which is 60 unless yours was raised. | Wait the number of seconds in the Retry-After header. If a 429 has no Retry-After, wait a few seconds, then send it again. |
| 503 | service_ | We're busy right now and a GET request didn't finish. | Wait the number of seconds in the Retry-After header, then send it again. |
Sending
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | sender_ | The request has no from, and your organization has no default sender name. | Send from, or set a default sender name in the portal. |
| 400 | unapproved_ | The sender name in from isn't approved for your organization. | Use an approved sender name, or InfoSMS. |
| 400 | sender_ | The sender name can't be used for one of the destination countries. | Use another sender name for that country. |
| 400 | default_ | bodies has no text for your organization's default language. | Add the default language's text to bodies. |
| 400 | invalid_ | A number in to couldn't be matched to a country. | Send numbers in international format, like +442079460123. |
| 400 | no_ | We don't send to one of the destination countries. | Remove those numbers. |
| 400 | currency_ | A destination country has no price in your organization's currency. Nothing was sent or charged. | Remove those numbers, and email us. |
| 400 | not_ | This message can't be sent again. | Send a new message instead. |
| 400 | all_ | We can't send to any of the numbers. Anyone else in the request opted out. Nothing was sent or charged. | Check the numbers are right. If they are, email hello@codelia.studio. |
| 400 | all_ | Your organization can't send to these countries yet, and no one else in the request is left to send to. Nothing was sent or charged. | Email hello@codelia.studio to send to them. |
| 402 | insufficient_ | Your balance can't cover the messages. Nothing was sent. | Top up in the portal, then send again with a new Idempotency-Key. |
| 403 | country_ | Sending to one of the destination countries isn't available right now. | Remove those numbers, or try again later. |
| 403 | feature_ | Your organization isn't approved to send transactional messages. Nothing was sent, scheduled or charged. | Request access in the portal, or send it as a marketing message. See Transactional messages. |
| 403 | organization_ | Your organization is suspended, so it can't send. Reading still works. | Email us. |
| 403 | sending_ | This request couldn't be accepted. Nothing was sent or charged. | If you expected it to go out, email hello@codelia.studio. |
| 502 | provider_ | The message couldn't be handed to the network. | Check your balance and the message's status. If it didn't go out, send it again with a new Idempotency-Key: the same key returns this answer again. |
When every number in a request has opted out, the request is refused with all_. See Opt-outs.
Campaigns and recurring campaigns
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | invalid_ | scheduledAt is less than 5 minutes or more than 90 days ahead. | Choose a time in that window, or leave it out to send now. |
| 400 | too_ | The lists and recipients come to more than 100,000 people. | Split the audience across campaigns. |
| 400 | unknown_ | A list in listIds doesn't exist in your organization. | Check the list IDs. |
| 400 | no_ | The lists and recipients came to nobody. | Add people to the list, or send recipients. |
| 400 | all_ | We can't send to any of the numbers. Anyone else in the request opted out. Nothing was sent, scheduled or charged. | Check the numbers are right. If they are, email hello@codelia.studio. |
| 400 | all_ | Your organization can't send to these countries yet, and no one else is left to send to. Nothing was sent, scheduled or charged. | Email hello@codelia.studio to send to them. |
| 400 | reserved_ | A metadata key starts with audience.. | Rename the key. |
| 400 | invalid_ | The rule never gives a date to send on, the recurring campaign's send has scheduledAt, endsAt leaves no time to send on, or an ended campaign was resumed without room for another. | Fix the rule, take scheduledAt out of send, or move endsAt or raise maxOccurrences. |
| 400 | transactional_ | A recurring campaign's send has type set to transactional. | Schedule each transactional message on its own, or repeat it as a marketing message. |
| 400 | invalid_ | The cursor came from a different view of the campaign list. | Pass nextCursor back with the view it came from. |
| 409 | auto_ | Scheduling needs auto top-up, and yours isn't set up to pay for it. | Set up auto top-up in the portal, then try again. |
| 409 | not_ | The campaign is sending, has finished, or was canceled. | A campaign that stops part-way can be canceled once it reads stalled: true. |
| 409 | not_ | The campaign isn't scheduled any more. | Only a scheduled campaign can move. |
| 409 | not_ | The campaign isn't stalled. | Only a campaign with stalled: true can be resumed. |
| 409 | not_ | Only a campaign that failed before it was accepted (a scheduled campaign when it was due, or a large campaign sent now), with a failureReason other than all_ or unknown_, can be sent this way, and only once. sentAgainCampaignId names the campaign it was already sent as, and is null while that campaign is still being created. | Open that campaign. To repeat a campaign that went out, see Send to the same people again. |
| 409 | nothing_ | The campaign has no messages to send again, or, with onlyFailed, none that failed apart from people who were skipped or whose placeholders couldn't be filled in. | Nothing to do. |
| 409 | not_ | The recurring campaign was deleted. | Create a new one. |
| 409 | unsupported_ | A smart list's filter can't be read. | Edit the list to rebuild its filter. |
A campaign sent now to more than 500 people is accepted shortly after the request is answered. Until then it's refused only for a problem with the request itself, a sending limit already reached, or a balance at or below zero that auto top-up can't add to. Anything found once it's accepted, such as insufficient_ or too_, arrives as the campaign's failureReason instead. See Large campaigns.
Contacts and lists
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | invalid_ | The phone number couldn't be read as an international number. | Include the country code, like +442079460123. |
| 400 | smart_ | A filter uses a smart list, and a filter can use only static lists. | Filter on static lists only. |
| 400 | unknown_ | A filter uses a list that doesn't exist in your organization. | Check the list IDs in the filter. |
| 404 | contact_ | An import's listId isn't a list in your organization. | Check the list ID, or send listName instead. |
| 409 | contact_ | A contact with this phone number already exists in your organization. | Update that contact instead. |
| 409 | contact_ | A list with this name already exists. | Choose another name. |
| 409 | list_ | A change would turn a static list into a smart list, or the other way. | Create a new list of the kind you need. |
| 409 | list_ | A smart list's filter uses this list, so it can't be deleted. | Change that smart list's filter, or delete it first. |
| 409 | reserved_ | The built-in list of all your contacts can't be changed. | Create a list of your own. |
| 409 | reserved_ | The built-in list of all your contacts can't be deleted. | Nothing to do. |
| 409 | smart_ | Your organization already has 25 smart lists. | Delete one before you create another. |
| 409 | smart_ | People can't be added to or removed from a smart list by hand. | Change its filter instead. |
| 409 | smart_ | An import can't add people to a smart list. | Import into a static list. |
Opt-outs
| Status | error | What happened | What to do |
|---|---|---|---|
| 400 | all_ | Every number in to has opted out of your marketing messages. | Nothing was sent or charged. Don't retry the same numbers. |
Webhooks
| Status | error | What happened | What to do |
|---|---|---|---|
| 409 | delivery_ | You replayed a delivery that's still being tried. | Wait until it finishes, then replay it. |
| 409 | event_ | You replayed an opt-out event to an endpoint a connected app created, and that app can no longer see opt-outs. | Give whoever connected it opt-outs:read again, or reconnect it with that permission. |
A webhook URL the API refuses answers validation_, with the reason in errors.url. See Webhooks.
Where a table says "Email us", write to hello@codelia.studio.
A message that was accepted but didn't arrive has its own errorCode. Get the message to read it, or see After you send.
Rate limit
Each key can make 60 requests a minute by default. Every key has its own count, so one busy key never slows another. The API reports where you stand in response headers:
| Header | Meaning |
|---|---|
RateLimit-Limit | Requests allowed in the window: 60 unless your key's was raised |
RateLimit-Remaining | Requests left in this window |
RateLimit-Reset | Seconds until the window starts again |
RateLimit-Policy | The limit and the window in seconds, like 60;w=60 |
Over the limit, the API answers 429 with the code rate_ and a Retry-After header: the seconds to wait before the next request. When we're busy, a 429 can also come without our JSON body. If a 429 comes without a Retry-After, wait a few seconds, then send the request again. To message many numbers at once, put up to 500 in one request's to rather than making one request each.
If you need a higher limit, email us at hello@codelia.studio.
Retry safely with an Idempotency-Key
Add an Idempotency-Key header when you send, and a retry with the same key and body gets the first answer back once the first request has finished, marked Idempotency-Replayed: true, instead of sending twice. A key lasts 24 hours.
Idempotency-Key: order-1042-readyRetrying safely lists the requests that take a key, says what a repeat gets back, including after an error, and what to do when you can't tell whether a request went through.