Pick what to send
One command sends every kind of message. Pick the kind that fits
Every message goes out through one command, POST /v1/commands/message.send. The body has two parts: target says who gets it, and payload says what it is. Set payload.kind to the kind of message.
{
"target": { "conversationId": "a0000000-0000-4000-8000-000000000001" },
"payload": { "kind": "text", "text": "Yes, by the window." }
}Kinds
| You want | kind | Guide |
|---|---|---|
| Words | text | Text |
| A photo or file | media | Images and files |
| Text and photos as one message | multipart | Images and files |
| A link with a preview card | link | Links |
| A sticker | sticker | Stickers |
| Ask for a location | location_request | Location |
| A poll | poll | Polls |
| A card from your iMessage app | app_card | App cards |
| A place on a map | location | Location |
| Contact cards | contact | Contact cards |
| Buttons or a list to pick from | choices | Buttons and lists |
| An approved template | template | Templates |
Channel support shows which kinds each channel takes.
Who gets it
Name a conversation, or a person.
- A conversation:
target.conversationId, from amessage.receivedevent or List conversations. Mapier sends from the same line, on the same channel. - A person:
target.recipientExternalId, their address in the channel's own form. A first message to someone new opens a conversation.
| Channel | Address | Who writes first |
|---|---|---|
| iMessage | A phone number with a plus sign and country code, such as +14155550123 | Your agent, with a plain text. Other kinds go only into a conversation the person has written in, or a group chat, so send a text first and use the conversationId that comes back |
| A phone number, as on iMessage | Your agent, with a template. Within 24 hours of the person's last message, any kind can go |
What a line cannot carry
If a payload key the line does not take carries a value, the send is refused with 422 validation_failed naming that key, and nothing is sent. A key set to null or to an empty list is ignored. To let Mapier drop or split what the channel cannot carry instead, such as an effect, send options.degrade: "adapt". The 202 then lists what it changed in adaptations.
After you send
202 Accepted means Mapier accepted the request, not that the message arrived. The command's result says whether it went out: event: command on the stream, command.settled at a webhook. Delivered and read arrive later. Results and delivery explains each one. A retry with the same Idempotency-Key never sends twice; Retries explains.