Skip to main content

Errors

Every error from the Mojeeb Public API uses the same envelope. Branch on code (stable, forever-additive) — never on message (human-readable, may be reworded without notice).

What does an error response look like?​

{
"error": {
"type": "validation_error",
"code": "invalid_from_phone",
"message": "The 'from' field must be an E.164 phone number...",
"param": "from",
"correlation_id": "req_01KQ..."
}
}
FieldAlways present?Purpose
typeYesStable category for catch blocks
codeYesStable, specific reason — branch on this
messageYesHuman-readable; never use as a key
correlation_idYesTrace id for our logs — quote in support tickets
Extra fieldsSometimesPer-error context (e.g. param, available_phones, original_correlation_id)

What are the error types?​

A small, stable set of categories. Forever-additive — new types may appear, none will be removed:

typeTypical HTTP
authentication_error401
permission_error403
validation_error413, 422
idempotency_error409 / 422
rate_limit_error429
quota_error402
conflict_error409
not_found_error404
internal_error500, 503 (and 401 when the key couldn't be checked)

What's the full code catalog?​

Codes are a stable enum. New codes appear without notice; nothing existing will be renamed or repurposed.

codeHTTPMeaning
invalid_api_key401Missing, malformed, unknown, revoked or expired key. Fix your Authorization header.
invalid_token401An AI assistant's sign-in token expired or its connection ended. The assistant renews it, or asks the person to sign in again.
insufficient_scope403Key lacks the required scope (response includes required_scope).
insufficient_role403Managing the team: the key is limited to some agents, or the person who created it (or who signed the assistant in) can't do this in the dashboard any more (only the owner, or an admin with every agent, manages the team, and only the owner removes someone). For an AI assistant: the person it acts for has a role too low for the endpoint, such as a rep sending WhatsApp messages.
owner_only403The teammate is an owner. Owners are managed in the dashboard, never with a key.
self_edit, self_remove403The teammate is the person who created the key: nobody changes or removes their own access.
agent_not_authorized403Key is restricted to specific agents and this one isn't on its list.
agent_not_granted403The person an AI assistant acts for has no access to this agent.
shared_with_other_agents403The knowledge base, or a custom API tool's site login, is also used by agents the key can't act on, so the key can't change it.
feature_not_available403Your plan doesn't include this: custom API tools are on paid plans, and broadcasts on plans that include them. Upgrade, or use the endpoints your plan has.
not_note_author403Only a note's author can edit or delete it; a key acts as the person who created it.
system_note_read_only403Notes Mojeeb records, such as lead status changes, can't be edited or deleted.
upload_token_invalid403Sending an upload's bytes: X-Upload-Token is missing, isn't this upload's, or is past its 15 minutes. Create a new upload.
agent_not_found404The agent isn't one of your organization's agents.
not_found404The conversation, contact, note, lead, lead field, ticket, ticket field, knowledge base, connection, custom API tool, AI attachment, saved reply, comment or broadcast isn't the agent's (a deleted conversation is not found too), a conversation's message you asked for isn't one of its messages, the connection whose templates you asked for isn't a WhatsApp number, the WhatsApp template isn't among the number's templates, or a broadcast's connection_id isn't one of the agent's WhatsApp numbers. On the team endpoints, the person isn't on the team, or the invitation isn't one of your organization's open invitations. On the usage history, your organization has no subscription.
message_not_found404GET /v1/whatsapp/messages/{id}: the id doesn't exist, belongs to another organization, or was sent through an agent outside the key's agent list.
endpoint_not_found404No /v1/ endpoint matches the method and path, including an id that isn't a UUID. Check for typos.
upload_not_found404No upload of this agent has that id: its bytes were never sent, it's another agent's, or it's past its 24 hours.
lead_capture_not_found404The agent has no Capture Lead tool, so it has no lead capture prompt to read or change. Contact Mojeeb support to have the tool added.
ticket_capture_not_found404The agent has no Create Ticket tool, so it has no ticket capture prompt to read or change. Contact Mojeeb support to have the tool added.
invalid_request_body422A field is missing, has the wrong type, breaks a limit or a format (such as a lead phone or contact mobile that isn't E.164), or a query parameter's value isn't valid (response includes param naming it).
invalid_request422A business rule refused the change (for example an unknown lead or ticket status, a reserved lead or ticket field key, or a conversation, lead or contact that isn't the agent's given for a new ticket), the cursor isn't one the API returned, or a message list's after isn't a message of the conversation or was sent together with cursor (both with param: after). On a broadcast: a recipient lacks a body value (param names it), the audience is larger than the number's WhatsApp daily messaging limit, or a retried broadcast has no failed recipient. On a saved reply: another of the agent's saved replies uses the shortcut, the saved reply would be left with neither text nor media, or its media isn't one image, video or document or up to 10 images. The message says which.
invalid_date_range422The analytics window is out of bounds: to is before from, a date is later than today in UTC, or the window is longer than the endpoint allows. The message says which.
no_settings422A settings or conversation update sent nothing to change.
messaging_window_closed422A reply in a conversation whose customer hasn't written in the last 24 hours: WhatsApp, Facebook and Instagram won't deliver it. Nothing was sent. On WhatsApp, send a template.
channel_not_supported422A reply in a conversation on a channel Mojeeb can't send on yet (TikTok). Nothing was sent.
comment_already_hidden422hideComment on a comment that is hidden already.
comment_not_hidden422unhideComment on a comment that isn't hidden.
platform_hide_failed422Facebook or Instagram refused to hide or show the comment, for example because it was deleted, or couldn't be reached. It can be temporary.
field_not_writable422An agent update sent a value for a field a key can't change: status (so a key can't delete an agent), ai_model, model_provider, avatar_url or language (response includes param naming it). Nothing was changed.
unknown_timezone422time_zone isn't an IANA time zone id in Region/City form, such as Africa/Cairo (UTC is Etc/UTC).
invalid_ai_schedule422ai_schedule can't be saved: switched on with no window, too many windows, a window with no day, a day outside 0 to 6, or a time that isn't HH:mm. The message says which.
invalid_follow_up_platform422A follow-up channel isn't whatsapp, facebook or instagram.
invalid_follow_up_steps422More steps than allowed, a delay out of range, or two steps with the same delay.
assignee_not_allowed422The teammate can't open the agent (they aren't in your organization, or they're limited to other agents), so the lead, ticket or conversation can't be assigned to them. Pick someone with can_open_agent: true on the agent's members list.
invitation_not_pending422The invitation is no longer open: it was accepted, or it expired and its link was then used. It can't be sent again; invite the person again instead.
unknown_agent422One of agent_ids isn't an agent of your organization.
too_many_agents422More than 100 agent_ids. Give every agent with all_agents: true instead.
system_field422A built-in lead or ticket field (built_in: true), the lead or ticket statuses included, can't be changed or deleted through the API.
lead_field_limit_reached422The agent already has as many custom lead fields as the API can add. Delete one it no longer needs first.
ticket_field_limit_reached422The agent already has as many custom ticket fields as the API can add. Delete one it no longer needs first.
connection_inactive409The connection is disconnected (active: false), so its settings can't be changed, its templates can't be read or managed, and broadcasts can't be sent or retried from it. Reconnect it in the dashboard first.
connection_needs_reconnection409Meta no longer accepts the WhatsApp number's access (it was revoked or expired, or the number left its WhatsApp Business Account), so its templates can't be read or managed and broadcasts can't be sent or retried from it. Reconnect the number in the dashboard; retrying won't help.
template_name_taken409The WhatsApp number already has a template with this name in this language. A create retried after a lost response lands here too, so list the templates and carry on.
template_limit_reached409The WhatsApp Business Account has as many templates as Meta allows. Delete one it no longer needs first.
template_status_not_allowed409The template's status doesn't allow the change: only an approved, rejected or paused template can be edited, and only an approved, rejected, paused or pending one can be deleted.
template_edit_limit_reached409Meta's edits for this approved template are used up (one a day, ten a month). Try later, or create a new template.
template_in_use_by_broadcast409A broadcast is sending this template right now. Try again when it finishes.
template_reserved409Mojeeb's own notifications use this template, so it can't be deleted.
template_delete_locks_name409Deleting this approved or paused template locks its name at Meta for 30 days. Send acknowledge_name_lock=true to delete it.
already_member409The person you invited is already on the team. Nothing was sent.
broadcast_still_sending409The broadcast is still sending, so its failed recipients can't be sent again yet. Retry when it has finished. A broadcast cut off by a restart can stay sending: contact support.
test_chat_busy409The last message in this test chat is still waiting for its answer. Nothing was saved. Read the answer from the conversation's messages, then send the next message.
field_key_taken409The agent already has a lead field (or, for a ticket field, a ticket field) with this key, built-in fields included. Nothing was created. A create retried after a lost response lands here too, so list the lead or ticket fields and carry on.
too_many_leads409Changing many leads' status (changeLeadsStatus): more leads would change than max_changes, because new leads arrived or leads crossed into the time window since the dry run. Nothing was changed. Send a dry run again and confirm the new number before you call with it.
too_many_tickets409Changing many tickets' status (changeTicketsStatus): more tickets would change than max_changes, because tickets arrived or went quiet since the dry run, or the filters differ from the dry run's. Nothing was changed. Send a dry run again and confirm the new number before you call with it.
no_current_usage_period409No billing period of your subscription covers now, so Mojeeb treats it as not renewed and the AI doesn't reply until a period opens. It clears when the renewal lands; if it lasts, contact support with the correlation_id. GET /v1/organization/usage also answers it when your organization has no subscription at all.
usage_periods_overlap409More than one billing period of your subscription covers now, so Mojeeb can't tell which limits apply. Contact support with the correlation_id.
login_shared409The custom API login you sent differs from the site's saved one, or carries a secret, and other tools use it. Send change_shared_login: true to change it for all of them, or leave login out.
tool_not_tested409A custom API tool can be switched on only after a passing test of its current request. Test it, then switch it on.
attachment_has_no_media409active: true on an AI attachment with no media stored: the AI would have nothing to send. Upload or import its media first. Nothing was changed.
too_many_active_attachments409The agent already has 100 active AI attachments. Switch one off first. Nothing was changed.
attachment_type_locked409An AI attachment's type can't change once media is stored, because the files were checked against it. Add a new attachment of the other type instead. Nothing was changed.
upload_already_written409This upload's bytes were already sent; an upload is written once. Create a new upload to send another file.
request_body_too_large413The request body is larger than 1 MB, or, on an AI attachment's media upload (uploadAttachmentMedia), larger than 51 MB, or, on an upload's bytes (putUploadContent), larger than 20 MB.
invalid_agent_id422agent_id isn't a valid UUID (WhatsApp endpoints).
invalid_phone_number422to isn't a valid E.164 number (WhatsApp endpoints). A lead phone or contact mobile that isn't E.164 is invalid_request_body.
invalid_from_phone422from isn't a valid E.164 number.
from_phone_not_found_for_agent422from is well-formed but doesn't match any active WhatsApp connection on the agent (response includes available_phones).
recipient_required422A WhatsApp send named neither to nor recipient_username; send one of them. Nothing was sent.
recipient_conflict422A WhatsApp send named both to and recipient_username. They could be different people, so Mojeeb picks neither: send one. Nothing was sent.
recipient_not_found422No customer with that recipient_username has messaged the agent's WhatsApp number, or another of its numbers on the same WhatsApp Business Account. WhatsApp only lets a business message a username after its owner writes first: send to their phone in to, or ask them to message you. Nothing was sent.
auth_template_needs_phone422An authentication template (one-tap, zero-tap or copy-code) to a customer known only by WhatsApp username. WhatsApp delivers those by phone number only. Nothing was sent.
template_header_media_url_invalid422On a send, template.header_media_url isn't an absolute HTTPS URL, or it's a Mojeeb upload that names no usable upload of the agent or doesn't match the template's header format (an image header takes JPEG or PNG, a video header MP4, a document header PDF). On a template create or edit, Mojeeb couldn't download or read header.media_url (param: header.media_url); the message says why.
template_rejected422Meta refused the template you created or edited, and the message is Meta's reason; or Mojeeb refused an edit Meta wouldn't take (an approved template's category, a switch between numbered and named variables), and the message says why.
template_not_approved422A broadcast's template isn't approved, so it can't be broadcast. A retry checks it again, so a template paused since the send lands here too.
template_not_broadcastable422A broadcast's template has a header variable, or a button that needs a value per send, which a broadcast can't fill (send it one by one), or a location header, which Mojeeb can't send yet.
template_not_found422The connection has no template with that name, whatever its status (response includes available_templates). On a send, when Mojeeb can't read the templates from Meta, or the number has more templates than Mojeeb reads and this one isn't among them, this check is skipped and the send is accepted. A broadcast needs the template, so it never skips: a number Meta won't list answers as listing its templates does, and a template past the ones Mojeeb reads is this error without available_templates.
template_not_found_for_language422The template has no version in that language, whatever its status (response includes available_languages). A send skips this check as it skips template_not_found.
invalid_media422An AI attachment's upload or import: no file, too many files for the type, an empty or too large file, or a file that isn't a kind the type takes (checked by its content, not the type it was sent with). The message names the file. Nothing stored was changed. On a reply in a conversation: the media_url file's bytes don't pass. Nothing was sent.
attachment_media_url_invalid422An AI attachment's import: a link isn't https, points at an address that isn't public, can't be reached, answers anything but 200 with the file within 20 seconds (redirects aren't followed), sends a file too large for the type, or names an upload that isn't this agent's or is past its 24 hours (param: urls). Nothing stored was changed.
media_url_invalid422A reply's or WhatsApp message's media_url, or a link in a saved reply's media_urls, can't be read, isn't a file a message carries, or names no upload of the agent (param names it). Nothing was sent or stored.
upload_too_large422Creating an upload: size_bytes is 0 or over 20 MB.
upload_size_mismatch422Sending an upload's bytes: the body isn't exactly size_bytes long.
upload_type_not_allowed422The upload's bytes aren't a JPEG, PNG or WebP image, an MP4 or MOV video, or a PDF or DOCX document. The message names the file.
upload_url_invalid422Creating an upload from file: Mojeeb couldn't download file.download_url.
idempotency_key_in_progress409A request with this key is still running, or one with it that was refused or failed after claiming the key (for example a reply's messaging_window_closed) started less than 60 seconds ago, whatever the body. Retry after Retry-After, or send the corrected request with a new key.
idempotency_key_in_use_with_different_params422The key belongs to an earlier accepted request that differs from this one: another body, or another endpoint or conversation (the same text replied in another conversation counts as different). The response includes original_correlation_id.
idempotency_unknown_outcome500An internal fault in the idempotency check (not expected). Retry with the same key and body.
unknown_send_outcome500An internal fault mapping the send result (not expected). Look up the message before sending again.
rate_limit_exceeded429Per-key rate limit hit: the default one, or the lower one of the WhatsApp template endpoints, broadcast sends and retries, invitation sends and resends, and AI attachment media uploads and imports (uploadAttachmentMedia, importAttachmentMedia), creating an upload (createUpload) and putting media on a saved reply (importSavedReplyMedia), or of replies in a conversation. Back off and retry after Retry-After.
video_send_rate_limited429The key sent 10 videos this minute in replies' and WhatsApp messages' media_url, which are re-encoded. Retry after Retry-After, or send a file that isn't a video.
test_rate_limited429Your company ran too many custom API tool tests this minute (30, across its keys and the dashboard). Retry after Retry-After.
message_limit_exceeded402Your plan's messages for this period are used up, so the agent can't answer a test chat message. Nothing was saved; limit and used carry the numbers. Sends and replies don't check it today.
access_unavailable503The access check couldn't run: the key's, or when assigning a lead or a conversation, the teammate's. Retry with backoff.
meta_unavailable503Meta didn't return what was asked, such as a WhatsApp number's templates (an outage, a timeout or Meta's own rate limit), or didn't confirm a template create, edit or delete in time. Retry with backoff. After a template create, edit or delete, read the template first: the change may have been made.
media_processing_busy503Uploading or importing an AI attachment's video: videos are re-encoded a few at a time across Mojeeb, and every slot stayed busy for 30 seconds. Nothing stored was changed. Send the same request again after Retry-After.
internal_server_error500, 401Our problem: retry with exponential backoff, and if it persists, send us the correlation_id. With 401 it means we couldn't check the key; retry, don't rotate it.

What HTTP statuses can the API return?​

StatusMeaning
200Success with a body (a read, an update, an assignment, a test chat message or an upload's bytes)
201Resource created (a lead, a note, a knowledge base, a lead field, a custom API tool, an AI attachment, an upload, a saved reply, a WhatsApp template, a reply in a conversation, a broadcast, an invitation)
202Accepted for async processing (a message queued for send, a broadcast's failed recipients sent again)
204Success with no body (a delete)
401Authentication failed
402Your plan's messages are used up (a test chat message)
403Authorization failed (an upload's token, scope, agent list, shared knowledge or login, note author, a feature your plan doesn't include, or a team change the key can't make: its creator's rank or its agent list, an owner, or its own creator)
404Resource not found
409Conflict (idempotency key in progress, a disconnected connection or one that needs reconnecting, a lead field key that already exists, more leads to change than max_changes allows, no single current billing period, a shared custom API login, an untested tool, a WhatsApp template that can't change now, a broadcast still sending, a test chat still waiting for its answer, someone already on the team, an AI attachment without media, past the agent's active limit or whose type is locked, or an upload whose bytes were already sent)
413Request body larger than 1 MB (51 MB on an AI attachment's media upload, 20 MB on an upload's bytes)
415The body isn't sent as application/json (a standard problem-details body, not the envelope)
422Validation error, including a body that isn't valid JSON
429Rate limit exceeded
500Internal error
503The access check or Meta temporarily unavailable, or video processing busy

Which errors should I retry?​

Retry only the temporary ones. Wait for Retry-After on 429, on 409 idempotency_key_in_progress and on 503 media_processing_busy. Use exponential backoff on other 503 errors, on 500 errors except unknown_send_outcome, on 422 platform_hide_failed (Facebook or Instagram may just be unavailable), and on a 401 whose code is internal_server_error. After a 503 on a template create, edit or delete, read the template before you retry. Every other error needs a change before you send the request again.

ErrorWhat to do
409 connection_inactive, 409 connection_needs_reconnectionReconnect the connection in the dashboard, then try again.
409 field_key_takenThe field already exists: list the agent's lead or ticket fields and carry on.
409 too_many_leads, 409 too_many_ticketsDon't send it again as it is: send a dry run again, confirm the new number, then call with it as max_changes. Never raise max_changes without confirming.
409 no_current_usage_periodWait: it clears when the renewal lands. Contact support if it lasts. With no subscription at all it won't clear until you subscribe.
409 usage_periods_overlapContact support with the correlation_id.
409 login_sharedLeave login out, or send change_shared_login: true if every tool on the site should change.
409 tool_not_testedTest the tool, then switch it on in a request of its own.
409 attachment_has_no_mediaUpload or import the attachment's media, then switch it on.
409 too_many_active_attachmentsSwitch off an attachment the agent no longer needs, then try again.
409 attachment_type_lockedAdd a new attachment of the type you want, and switch the old one off.
409 template_name_takenThe template exists: list the templates and carry on, or pick another name.
409 template_in_use_by_broadcastWait for the broadcast to finish, then try again.
409 template_edit_limit_reachedTry again tomorrow, or create a new template.
409 template_delete_locks_nameSend acknowledge_name_lock=true if the name can stay locked for 30 days.
409 broadcast_still_sendingRead the broadcast until status is no longer sending, then retry it. If it stays sending long after its messages stopped, contact support.
409 test_chat_busyRead the test chat's messages until the answer arrives, then send the next message.
402 message_limit_exceededWait for the next billing period, or upgrade your plan.
500 unknown_send_outcomeLook up the message before sending it again.
503 media_processing_busySend the same request again after Retry-After.
422 attachment_media_url_invalidFix the link the message names (a direct https link that answers 200 with the file), or upload the file instead.
422 media_url_invalidFix the link the message names (a direct https link that answers 200 with the file), or create an upload and send its url.
403 upload_token_invalid, 409 upload_already_written, 404 upload_not_foundCreate a new upload, and send its bytes once, within 15 minutes.
422 upload_size_mismatchCreate a new upload with the file's exact size in bytes.
422 invalid_mediaSend the file the message names again as a kind and size the attachment's type takes (a photo as JPEG, PNG or WebP up to 5 MB, for one), or one file for anything but an album.
422 messaging_window_closedWait for the customer to write, or, on WhatsApp, send a template.
422 platform_hide_failedTry again later, with backoff. If it keeps failing, the comment was probably deleted.
422 comment_already_hidden, 422 comment_not_hiddenNothing to fix: the comment is already as you asked. After a 500, it means your first request went through.
Any other 4xxFix the request; the code and message say what to change.

How do I use the correlation_id?​

Save it on every error. When you contact support, paste the correlation_id from the failing response — we can trace the entire request lifecycle in our logs in seconds.

You can also send your own trace id and we'll honor it when it's valid:

curl ... -H "X-Correlation-ID: my-app-trace-abc123"

Up to 128 characters: letters, digits, _ and -. An id that breaks these rules is ignored without an error and we generate one instead, so take the id from the response header rather than assuming yours was kept. We reflect the id in X-Correlation-ID on the response and embed it in any error body. If you don't send one, we generate req_<26-char ULID>.

Common questions​

Why does invalid_api_key cover so many sub-cases?​

A single code keeps client logic simple — your code only needs one branch for "auth failed." The message field disambiguates for humans debugging, but you should never branch on text. Treat any invalid_api_key as "fix the key and retry."

Will you add new error codes later?​

Yes. New code values can appear without notice as we add features. Keep your switch/match statements default-safe — fall back to "unknown error, log and surface to user."

What about field-level errors with multiple invalid fields?​

Currently the API returns the first validation error encountered. We may add a richer multi-error shape later as an additive change (a new optional field on the envelope, never replacing existing fields). For now, fix one error at a time.

What's original_correlation_id?​

Returned on idempotency_key_in_use_with_different_params. It points to the trace id of the request that originally claimed the idempotency key, so you can find that earlier request in your own application logs.

What's available_phones?​

Returned on from_phone_not_found_for_agent. Lists every active WhatsApp number on the agent in E.164 format, so you can self-correct your from value without a second roundtrip to discover what was valid.