MessageOS
API

Errors

Error codes returned by the MessageOS API.

Every error uses one body:

{ "error": { "code": "validation_error", "message": "Attributes are not valid.", "requestId": "req_3f2a9c1d7e5b4a60", "details": [{ "path": "tier", "message": "Unknown key" }] } }

code is stable. message is for people and can change. details lists field problems when there are any, each with the path of the field. A blocked error also has reason.

CodeStatusMeaning
unauthorized401The key is missing, unknown, expired, or revoked
forbidden403The key does not have the scope, or this send is not allowed
not_found404Missing, hidden from this caller, or a feature that is not enabled
conflict409The request conflicts with stored data, a request with the same key is still in progress, or the messaging network would not take a message back
blocked409Nothing was sent or shown. reason says why, and message says what to do
payload_too_large413The request body is over the size limit, 1 MB
validation_error422The body, a query value, or a header is not valid, or the body is not JSON
idempotency_key_reuse422POST /v1/messages, POST /v1/knowledge, or POST /v1/events got a key it already saw with a different body
rate_limited429Over a per-minute request limit. MessageOS does not cap requests, so this is answered only if a limit has been set. Retry-After is in seconds
internal_error500The request could not be completed
provider_unavailable503The messaging network did not answer a capability check, a typing indicator, or a request to take a message back, or was busy or over its limit. Try again in a moment. A send never answers this: a send the network did not take is blocked
service_unavailable503MessageOS could not complete the request just now. Retry-After is the number of seconds to wait before sending it again

An unexpected failure returns 500 internal_error in the same shape, with a request id.

A 500 or a 503 can be sent again. Use the same Idempotency-Key and the same body, and wait the seconds in Retry-After first when the answer has that header. However often you retry, at most one message is sent. Idempotency says what a retry can answer.

A body field clientId or optedIn is rejected. Only a message from the person changes opt-in.

Why a message was blocked

A send that did not go out returns 409 with code blocked. reason is the stable cause, and message says the same in a sentence, with what to do next:

{ "error": { "code": "blocked", "reason": "opted_out", "message": "This person opted out. Nothing was sent. Only a message from them opts them back in.", "requestId": "req_3f2a9c1d7e5b4a60", "details": [{ "path": "reason", "message": "opted_out" }] } }

Branch on reason. details[0].message repeats it. The words of message can change.

reasonWhat message saysThe same Idempotency-Key again
opted_outThis person opted out. Nothing was sent. Only a message from them opts them back in.Gets this answer again
org_opted_outThis person opted out of this organization's messages. Nothing was sent.Gets this answer again
no_consent_recordThere is no consent record for this person, and they have not written in. Nothing was sent. Add consent to the request, or store it on the contact, then send again with a new Idempotency-Key.Gets this answer again
class_not_allowedThis agent does not send that class of message. Nothing was sent. GET /v1/whoami lists the classes it sends.Gets this answer again
template_requiredThis class of message needs a template for this agent. Nothing was sent. Send it again with template instead of text, with a new Idempotency-Key.Gets this answer again
quiet_hoursIt is quiet hours for this person. Nothing was sent. Send again when they end, with a new Idempotency-Key. Set onQuiet to defer to learn when that is.Gets this answer again
missing_timezoneQuiet hours could not be checked because neither the contact nor the agent has a time zone. Nothing was sent. Set the contact's timezone, then send again with a new Idempotency-Key.Gets this answer again
rate_limited_contactMessageOS has set a limit on how many messages one person receives, and this person has reached it for now. Nothing was sent. Send again later with a new Idempotency-Key.Gets this answer again
rate_limited_clientMessageOS has set a limit on how many messages one agent sends, and this agent has reached it for now. Nothing was sent. Send again later with a new Idempotency-Key.Gets this answer again
duplicateThe same message was sent to this person a moment ago. Nothing was sent.Gets this answer again
invalid_contentThe message has no content. Nothing was sent.Gets this answer again
contact_not_foundThat contact no longer exists. Nothing was sent.Gets this answer again
agent_pausedThis agent is paused. Nothing was sent.Gets this answer again
human_handledA person is handling this conversation. Nothing was sent.Gets this answer again
agent_not_availableThis agent cannot message this phone number yet. Nothing was sent. An agent that has not launched reaches only its testers, and an agent that is still being set up reaches no one. Ask MessageOS if this agent should be able to reach this number.Sends the message again
message_rejectedThe messaging network did not accept this message. Nothing was sent. The phone number may not be a mobile number it can reach, or the content may not be valid. Check both before sending again.Sends the message again
provider_busyThe messaging network is busy or over its limit. Nothing was sent. Wait, then send again with the same Idempotency-Key.Sends the message again
provider_errorThe messaging network did not confirm this message, so it is not reported as sent. It may still have gone out. You can send again with the same Idempotency-Key, and if the first one did go out the person gets it twice.Sends the message again

The last column says what the same Idempotency-Key and body get the next time. Most blocked answers are kept for the key, so a retry with it gets the same answer and nothing is tried again. To send again after quiet hours end or you add consent, use a new key.

A few of these need more than the sentence:

  • no_consent_record: a message you start needs a consent record for the person, or an earlier message from them. A phone number that is not yet a contact gets this reason too. Send consent in the same request and the contact is created with it. A reply sent with inReplyTo needs none.
  • quiet_hours and missing_timezone: these apply where GET /v1/whoami shows quietHoursEnforced true, or when the request sets onQuiet to reject or defer. A reply sent with inReplyTo is not held.
  • class_not_allowed: POST /v1/messages does not answer with this reason. A class your agent does not send is refused before the send rules run, with 422 validation_error, and details[0].path is class. allowedClasses in GET /v1/whoami lists the classes it sends. class_not_allowed is the reason when a draft is approved and its class is not one the agent sends.
  • rate_limited_contact and rate_limited_client: MessageOS does not cap how many messages you send, so a send gets one of these only if a send limit has been set. limits in GET /v1/whoami is null for each limit that is not set. Rate limits says what a limit counts.
  • duplicate: a send with its own Idempotency-Key is not checked for repeated words. This reason is for an approved draft.
  • agent_paused: only an event playbook message, such as an approved playbook draft, is held by a pause. Messages you send yourself are not.
  • agent_not_available, message_rejected, provider_busy, and provider_error: the messaging network did not take the message, or for provider_error did not confirm it. The answer is not kept for the Idempotency-Key, so the same key sends again. After provider_error the first message may have gone out, so sending again can reach the person twice.
  • provider_busy: the answer has a Retry-After header. Wait that many seconds, then send again with the same Idempotency-Key.

A repeat of POST /v1/messages with the same Idempotency-Key while the first request is still running is not a blocked answer. It answers 409 conflict with Retry-After: 1.

A message that was sent and then could not be delivered is not an error on the request. It arrives as the message.failed event, and GET /v1/messages/{id} shows failed.

Approving a draft can also return 403 forbidden with the reason test_session in details[0].message. The draft was written in a MessageOS test session, so it cannot be sent to the person. Nothing was delivered, and the draft is marked blocked.

On this page