Skip to content
Codelia SMSDocs
Guides: Errors and limits

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_error, and lists the problems by field in errors. A problem with the whole body is under _root:

{
  "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_error. 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_busy 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

StatuserrorWhat happenedWhat to do
400validation_errorA field is missing, has the wrong type, or is out of range. errors names each field.Fix the fields listed in errors.
400invalid_idempotency_keyThe Idempotency-Key header is empty or longer than 255 characters.Send a key of 1 to 255 characters.
401invalid_api_keyThe key is wrong, disabled, expired or revoked.Check the key on the API keys screen.
401invalid_tokenThe request had no API key, or the Authorization header didn't hold one.Send your key as Authorization: Bearer <your key>.
403insufficient_scopeThe key doesn't have the permission this endpoint needs.Add the permission named in the description, or use another key.
403api_key_not_allowedOnly a person signed in to the portal can use this endpoint.Use the portal.
403api_key_requiredThis endpoint only answers an API key.Call it with your key, not a portal session.
403not_permittedA 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.
404not_foundThe organization, message or other item in the path doesn't exist for your key.Check the account ID and the IDs in the path.
409idempotency_conflictA request with this Idempotency-Key is still running, or never finished.See Retrying safely.
422idempotency_key_reuseThis Idempotency-Key was already used with a different request.Use a new key for a new request.
429rate_limitedThe 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.
503service_busyWe'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

StatuserrorWhat happenedWhat to do
400sender_id_requiredThe request has no from, and your organization has no default sender name.Send from, or set a default sender name in the portal.
400unapproved_sender_idThe sender name in from isn't approved for your organization.Use an approved sender name, or InfoSMS.
400sender_country_not_allowedThe sender name can't be used for one of the destination countries.Use another sender name for that country.
400default_variant_requiredbodies has no text for your organization's default language.Add the default language's text to bodies.
400invalid_recipientA number in to couldn't be matched to a country.Send numbers in international format, like +442079460123.
400no_rate_for_countryWe don't send to one of the destination countries.Remove those numbers.
400currency_mismatchA destination country has no price in your organization's currency. Nothing was sent or charged.Remove those numbers, and email us.
400not_resendableThis message can't be sent again.Send a new message instead.
400all_recipients_unsupportedWe 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.
400all_recipients_not_allowedYour 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.
402insufficient_creditsYour balance can't cover the messages. Nothing was sent.Top up in the portal, then send again with a new Idempotency-Key.
403country_disabledSending to one of the destination countries isn't available right now.Remove those numbers, or try again later.
403feature_not_enabledYour 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.
403organization_suspendedYour organization is suspended, so it can't send. Reading still works.Email us.
403sending_limit_reachedThis request couldn't be accepted. Nothing was sent or charged.If you expected it to go out, email hello@codelia.studio.
502provider_unavailableThe 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_recipients_opted_out. See Opt-outs.

Campaigns and recurring campaigns

StatuserrorWhat happenedWhat to do
400invalid_schedulescheduledAt is less than 5 minutes or more than 90 days ahead.Choose a time in that window, or leave it out to send now.
400too_many_recipientsThe lists and recipients come to more than 100,000 people.Split the audience across campaigns.
400unknown_listA list in listIds doesn't exist in your organization.Check the list IDs.
400no_recipientsThe lists and recipients came to nobody.Add people to the list, or send recipients.
400all_recipients_unsupportedWe 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.
400all_recipients_not_allowedYour 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.
400reserved_metadata_keyA metadata key starts with audience..Rename the key.
400invalid_recurrenceThe 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.
400transactional_not_repeatableA recurring campaign's send has type set to transactional.Schedule each transactional message on its own, or repeat it as a marketing message.
400invalid_cursorThe cursor came from a different view of the campaign list.Pass nextCursor back with the view it came from.
409auto_topup_requiredScheduling 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.
409not_cancellableThe campaign is sending, has finished, or was canceled.A campaign that stops part-way can be canceled once it reads stalled: true.
409not_reschedulableThe campaign isn't scheduled any more.Only a scheduled campaign can move.
409not_resumableThe campaign isn't stalled.Only a campaign with stalled: true can be resumed.
409not_sendable_againOnly 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_recipients_unsupported or unknown_list, 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.
409nothing_to_resendThe 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.
409not_editableThe recurring campaign was deleted.Create a new one.
409unsupported_filterA 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_credits or too_many_recipients, arrives as the campaign's failureReason instead. See Large campaigns.

Contacts and lists

StatuserrorWhat happenedWhat to do
400invalid_phoneThe phone number couldn't be read as an international number.Include the country code, like +442079460123.
400smart_list_referenceA filter uses a smart list, and a filter can use only static lists.Filter on static lists only.
400unknown_list_referenceA filter uses a list that doesn't exist in your organization.Check the list IDs in the filter.
404contact_list_not_foundAn import's listId isn't a list in your organization.Check the list ID, or send listName instead.
409contact_existsA contact with this phone number already exists in your organization.Update that contact instead.
409contact_list_existsA list with this name already exists.Choose another name.
409list_kind_immutableA change would turn a static list into a smart list, or the other way.Create a new list of the kind you need.
409list_referenced_by_filterA smart list's filter uses this list, so it can't be deleted.Change that smart list's filter, or delete it first.
409reserved_list_not_editableThe built-in list of all your contacts can't be changed.Create a list of your own.
409reserved_list_not_deletableThe built-in list of all your contacts can't be deleted.Nothing to do.
409smart_list_limit_reachedYour organization already has 25 smart lists.Delete one before you create another.
409smart_list_not_editablePeople can't be added to or removed from a smart list by hand.Change its filter instead.
409smart_list_not_importableAn import can't add people to a smart list.Import into a static list.

Opt-outs

StatuserrorWhat happenedWhat to do
400all_recipients_opted_outEvery number in to has opted out of your marketing messages.Nothing was sent or charged. Don't retry the same numbers.

Webhooks

StatuserrorWhat happenedWhat to do
409delivery_in_flightYou replayed a delivery that's still being tried.Wait until it finishes, then replay it.
409event_not_permittedYou 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_error, 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:

HeaderMeaning
RateLimit-LimitRequests allowed in the window: 60 unless your key's was raised
RateLimit-RemainingRequests left in this window
RateLimit-ResetSeconds until the window starts again
RateLimit-PolicyThe limit and the window in seconds, like 60;w=60

Over the limit, the API answers 429 with the code rate_limited 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-ready

Retrying 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.