Send a message

Send a message, such as an iMessage, with one POST. Text, files or another kind, to a person or a conversation

POST/v1/commands/message.send

Sends one message on any channel. The result arrives later as an event.

Behavior

  • Returns 202 when accepted. The result arrives later as a command event on the stream, or a command.settled webhook.
  • A repeated Idempotency-Key returns the first 202, with "repeated": true.
  • 600 commands a minute per project. Rate limits lists every limit.
  • media holds one file, up to the size in Files. Several photos go as one multipart message, on iMessage.
  • Every refusal below comes back at once, before anything is sent, except a first text the line itself refuses (see Who gets it). A field the line cannot carry is 422 validation_failed. Nothing is dropped with a 202.

Headers

HeaderRequiredValue
AuthorizationYesBearer mp_live_…, your API key
Content-TypeYesapplication/json
Idempotency-KeyNo, but always send oneYour id for this send, 1 to 200 characters
x-mapier-versionNoThe API version date, such as 2026-12-01

Without x-mapier-version, you get your project's default. Versions explains.

Body

FieldTypeRequiredDescription
target.conversationIdstring (uuid)In the conversation formSend into this conversation, from its line
target.recipientExternalIdstringIn the recipient formThe person's address, in the form shown below. target.to is the same field
target.channelimessage or whatsappNoThe channel the person is on, such as imessage
target.lineIdstring (uuid)NoSend from this line
target.replyToMessageIdstring (uuid)NoQuote this message, in its conversation
payload.kindtext, media, sticker, multipart, location_request, poll, app_card, link, template, choices, location or contactNoWhat to send, one of the kinds below
options.degradestrict or adaptNostrict (default) or adapt to fit the channel

With adapt, Mapier drops or splits what the channel cannot carry, and lists each change in adaptations. A payload field the line does not carry, and that carries a value, is refused. body is read as a second spelling of text, and a field set to null is skipped.

Who gets it

Use one of these. Lines explains how a line is picked.

You haveSend
A conversationtarget.conversationId
A message to quotetarget.replyToMessageId
An address and a line to send fromtarget.lineId and target.to
An address and a channeltarget.channel and target.to
An address onlytarget.to, if all your lines are on one channel

target.to is also read as target.recipientExternalId, target.address, target.handle or target.recipient. A conversation named at target.conversationId wins over an address.

Address forms

Channeltarget.toExample
iMessagePhone number with + and country code+15550100100
iMessageTen digits without +, read as a US number5550100100
iMessageApple ID email, in an existing conversation onlyjordan@example.com
WhatsAppPhone number with + and country code+15550100100
WhatsAppWhatsApp user ID from Meta, when there is no phoneUS.Ab12

Kinds

kindFieldsGuide
texttextText
mediaurl, optional captionImages and files
multipartparts, each a text or a media urlImages and files
stickerurl or emojiStickers
linkurlLinks
locationlatitude, longitude, optional name, addressLocation
location_requestnothing beside itLocation
contactcontactsContact cards
pollquestion, optionsPolls
app_cardapp, url, layout, optional interactiveApp cards
choicesinteractive, or text with quickReplies or buttonsButtons and lists
templatename, language, componentsTemplates

kind: "rich_link" is deprecated. Use kind: "link". A kind the line's channel does not carry is 404 unsupported_command with reason: not_on_channel. Channel support shows which kind works where.

Each kind in detail:

Files

The most files one media message can hold, and the largest file, on each channel.

ChannelFiles per messageLargest file
iMessage1, or up to 20 parts in a multipart8 MiB
WhatsApp1Image 5 MiB (JPEG, PNG), video 16 MiB (MP4, 3GPP), audio 16 MiB, document 100 MiB

Channel options

FieldChannelDescription
payload.effectiMessageA bubble or screen effect, such as confetti
payload.subjectiMessageA bold subject line above the text
payload.textFormattingiMessageUp to 256 ranges: styles, text animations or mentions
payload.platform.whatsapp.previewUrlWhatsApptrue shows a preview of the first link

On iMessage these go beside text, on the conversation path.

What a line carries

Linemessage.send carries
iMessagetext — and, on the conversation path, effect, subject and textFormatting beside it; kind: "media" with an https link and no caption; kind: "sticker" with emoji or an image link, attachToMessageExternalId, partIndex and placement; kind: "link" with url; kind: "multipart" with parts (an effect and a subject beside them, as on a text); kind: "location_request" with nothing beside it; kind: "poll" with question and options; for an organization offered app cards, kind: "app_card" with app, url, layout (its picture at payload.layout.image), interactive and summary
WhatsApptext of at most 4,096 characters, with platform.whatsapp.previewUrl beside it; kind: "media" with an https url, which WhatsApp fetches itself, and an optional caption of 1 to 1,024 characters; kind: "sticker" with an https url to a WebP image; kind: "link" with url. Only within 24 hours of the person's last message

What every line does with the payload:

  • body is read as a second spelling of text.
  • A field set to null, an object holding only nulls and an empty attachments or media list say nothing and are skipped.
  • Any other field that carries a value is refused with 422 validation_failed at payload.<key> before anything is queued. That 422 carries the line's channel and the fields it carries in the same entry, and details names the field it stopped at.
  • A line of another channel carries what that channel's page lists under What works, and what GET /v1/capabilities lists for every channel, with each channel's own limits. A field it cannot carry is the same 422, and a kind it does not carry is 404 unsupported_command with reason: not_on_channel.

Photos and files go by link:

  • iMessage: kind: "media" with an https url of at most 2048 characters and no caption, fetched by Mapier before anything is written. Or as the parts of a multipart.
  • WhatsApp: kind: "media" with an https url and an optional caption of 1 to 1,024 characters. WhatsApp fetches the link itself.

A reply names a message in the same conversation at target.replyToMessageId, beside the payload and never in it. On the conversation path it is quoted when it names a message the person sent, or one of yours whose result carried an externalId. Any other reply, and every reply on the recipient path, is refused rather than sent unquoted.

Each refusal names the field it stopped at, before anything is written:

  • payload.<key>: a field the line does not carry, or a value outside its bounds.
  • payload.url: a media link Mapier cannot use.
  • payload.parts: a multipart's count, or a link twice. A part is refused at the part, payload.parts[i].url or payload.parts[i].text.
  • payload.emoji: a sticker's emoji that is not exactly one emoji.
  • payload.textFormatting: formatting outside its rules, or the range that breaks one at payload.textFormatting[i].
  • payload.app: an app card's app that your organization does not hold, a disabled one, or a name that differs from the one it registered.
  • target.replyToMessageId: a reply the line cannot quote.
  • target.conversationId, or the recipient field you wrote: an address or a conversation that cannot take what you sent.
  • target.lineId: a line on another channel, or not the line the conversation is on.

The whole list is under Errors. Who gets it says what each conversation can carry, and how a named line meets the line a person is already on.

Deprecated command names

whatsapp.template.send is deprecated. Send message.send with kind: "template".

whatsapp.interactive.send is deprecated. Send message.send with kind: "choices".

whatsapp.location.send is deprecated. Send message.send with kind: "location".

whatsapp.contacts.send is deprecated. Send message.send with kind: "contact".

Example request

curl -X POST https://api.mapier.ai/v1/commands/message.send \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-4821-ready" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": { "channel": "imessage", "to": "+15550100100" },
    "payload": { "kind": "text", "text": "Your order is ready." }
  }'

Response

FieldTypeSentDescription
commandIdstringAlwaysThe id the result on the stream carries
status"queued"Alwaysqueued, even on a repeat: the final status is in the result
repeatedbooleanWhen it appliestrue when this Idempotency-Key was used before
lineIdstring (uuid)AlwaysThe line that sends it
lineSelectionnamed, reused_active_chat or new_best_lineAlwaysWhy that line, one of the three values below
channelimessage or whatsappWhen it appliesThe channel that sends it
partsobject[], each { commandId, index }When it appliesWhen it went out as several messages: each part's command
adaptationsobject[], each { path, action, capability?, reason }When it appliesWith adapt: each change made to fit the channel
lineSelectionMeans
namedYou named the line
reused_active_chatThe line the person already talks to
new_best_lineA new person, so Mapier picked a working line with room
202 Accepted
{
  "commandId": "0192b3e1-7c2d-7a10-9b3e-4f5a6b7c8d9e",
  "status": "queued",
  "repeated": false,
  "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d",
  "lineSelection": "new_best_line",
  "channel": "imessage"
}

Results and delivery explains each final status.

Errors

Every refusal has the same body.

StatusCodeReasonWhenChannels
400bad_requestThe body is not valid JSONAll
401invalid_credentialsThe key is missing, unknown, revoked or expiredAll
403forbiddenThe credential may not make this call here. details.reason says why.All
403insufficient_scopeThe key lacks messages:sendAll
403line_not_allowednot_ownedtarget.lineId is not one of your project's linesAll
403recipient_not_allowedopted_outThe person opted outAll
403recipient_not_allowedblocked, pausedYou blocked or paused the person in the consoleAll
403recipient_not_allowedoutside_service_windowThe 24-hour reply window has closed. Send a template firstWhatsApp
403recipient_not_allowedrecipient_must_write_firstAn app card into a conversation nobody but your line has written in; or, from a test line on a shared number, a send to someone who has not texted the line, is no longer connected, or has left 20 turns or 100 messages unanswered since they last textediMessage
403recipient_not_allowedapp_card_needs_imessageAn app card into a conversation whose newest message did not go by iMessageiMessage
403recipient_not_allowedgroup_member_not_test_contactA send into a group on a test line on a shared number while someone in it is not one of this project's connected Test contactsiMessage
404not_foundNo conversation or message has that idAll
404unsupported_commandnot_on_channelThe channel has no such kindAll
404unsupported_commandnot_on_lineThis line cannot send that kindAll
404unsupported_commandshared_lineNot returned for a message.send: a test line on a shared number refuses only other commands with itiMessage
404unsupported_commandcommand_retiredThe command type was retired. details.use names the one to send instead.All
409conflictidempotency_key_in_flightThe first send is still runningAll
409conflictidempotency_key_failedThe first send failedAll
409conflictidempotency_key_unresolvedThe first send may have gone outAll
409conflictidempotency_key_reusedThe key was used for a different sendAll
409conversation_closedremoved, deleted, archived, suspendedThe group closed for this lineAll
409limit_reachedA daily cap on this test line on a shared number is reachediMessage
409project_archivedThe project is archivedAll
413payload_too_largeThe request body is over 65,536 bytesAll
422validation_failedA field is wrong; each details entry names oneAll
422validation_failedA link is over 2,048 charactersiMessage
422validation_failedAn app card's app is not one your organization holds, is disabled, or its name differs, at payload.appiMessage
422validation_failedmedia_too_largeA file is over 8 MiBiMessage
422validation_failedunsupported_media_typeA file's type is not allowediMessage
422validation_failedmedia_fetch_failedMapier could not fetch a file's linkiMessage
422validation_failedmedia_fetch_refusedThe link is not https, or points inside a private networkiMessage
429rate_limitedOver your request limit. Wait as the Retry-After header saysAll
429rate_limitederror_budgetThe channel refused many recent sends from this line. Wait details.retryAfterAll
429rate_limitedshared_lineA test line on a shared number spent its budget for your projectiMessage
429sandbox_budget_exhaustedNot returned today. Handle it like rate_limitedAll
500internal_errorMapier failed on its sideAll
503capacity_exhaustedall_lines_fullEvery line is full for new peopleAll
503line_unavailabletransport_downThe line's channel connection is down for nowAll
503line_unavailableline_pausedYou paused the lineAll
503line_unavailablechannel_not_availableThe project has no line on this channel.All
503line_unavailablesandbox_world_missingNot returned today. Handle it like channel_not_available.All
503line_unavailabletransport_unconfiguredThe line is not fully set up yet. Contact support if this lasts.All
503line_unavailableline_retiredThe line was retired from your project. Start a new conversation with the person on another line.All
503no_lineYour project has no working line on that channelAll
503service_busyMapier is busy, for example fetching many files. Wait details.retryAfterAll
503upstream_unavailableThe channel did not answerAll

A message the channel refuses after the 202 is still recorded: its result says failed, with the reason. Results and delivery lists every result code.

Guide

Pick what to send