Key concepts
The terms of the Mapier messaging API in plain words. A line, such as an iMessage number, a conversation, a command and the event stream
These words carry the rest of these docs. Nothing here needs code.
Line
A line is one sender on one channel, such as a phone number. A project can hold many lines, and one API key sends from all of them. GET /v1/whoami lists them under lines[], each with its id, its address and its channel. Lines says which line a message goes out on.
A conversation never moves to another channel, and Mapier never moves a message to another channel on its own.
Your WhatsApp line always has a different number from your iMessage lines: Mapier's iMessage numbers cannot be added to a WhatsApp Business Account. The people you talk to can be the same person on both channels.
Address
An address is how a channel reaches a person, and each channel has its own form. Mapier reads an address the way its channel does, and refuses one it cannot read with 422 validation_failed.
| Channel | Address |
|---|---|
| iMessage | A phone number in E.164 form, with a leading + (+14155550100), or an email address. Formatting is stripped, a bare ten-digit number is read as a US one, and an email address is lowercased. |
| A phone number with its country code. |
A phone number fits both iMessage and WhatsApp, so a project with lines on both names target.channel on a new send, or replies by conversationId.
A well-formed address is not proof that the person can be reached. GET /v1/reachability asks before you send to an address a person typed.
Conversation
A conversation is the messages between your line and one person, or a group chat, on one line. Mapier names it with a conversationId. That id is Mapier's own, and it is never the channel's id for the conversation.
You cannot make up a conversation id. It reaches you on each incoming message, and in the result of a command that acted on a conversation. To start a conversation with someone new, send to their address; later messages, and the result of that send, carry the conversation id. A group chat is a conversation too: a message in a group arrives under the group's own conversationId, and a send to that id reaches everyone in it.
Who may start a conversation depends on the channel:
| Channel | Who writes first |
|---|---|
| iMessage | Your agent. |
| Your agent, with an approved template. |
Message
A message is one bubble. Mapier names it with a messageId. A reply, an edit, an unsend, a reaction and a receipt lookup name a message by it. Each message also carries platformMessageId, the channel's own id for it, so you can match it with anything you already hold.
occurredAt on a message is when the channel says it was sent, not when Mapier received it. Your own sends do not come back to you as incoming messages.
Command
A command is how you change anything: send a message, add a reaction, start a group. Each one is a POST to /v1/commands/<type>, with a body of two parts:
{ "target": {}, "payload": {} }target says who the command acts on. payload says what it does. A command whose type says everything needs no body at all. The whole body is at most 65,536 bytes.
Mapier answers 202 Accepted with a commandId. A 202 means accepted, not sent. Mapier checked the request and recorded it; most mistakes in a message.send, such as text the channel cannot carry, are refused here with a 422 and nothing is sent. Whether the message then reached the channel arrives later, as the command's result. Send a message lists what is checked first.
Result
Each command ends in one result, which reaches you on the stream (and as a webhook), never in the 202. Match it to your command by commandId. It is one of six statuses:
| Status | Means |
|---|---|
succeeded | The channel took it. For a message, the channel now has it; that is not a delivery receipt. |
failed | It did not happen. failureClass says what kind of failure, and errorCode gives the channel's words. |
ambiguous | The channel took it, but could not confirm what happened. Treat it as unknown; do not resend blindly. |
no_effect | The channel took it, and found no change it could confirm. Handle it exactly like ambiguous. |
cancelled | It stopped before it ran. |
expired | It waited too long to run, and never did. |
Branch on the status first, then on failureClass, which is one of target, content, capability, line, rate_limited, not_run, transport (Mapier could not reach the channel) or unknown. Read errorCode for the detail, and quote it when you ask for help.
Delivered and read do not change a result. They arrive later as their own events, when you ask for them. Results and delivery explains each one.
The stream
The stream is one long-lived connection, GET /v1/response_stream, that carries every incoming message and every command's result for your project. You can ask it for more, such as receipts, reactions and polls.
Each event carries an id:. Keep the last one you handled, and reconnect with it as the Last-Event-ID header: the stream sends what you missed, up to 500 events at a time and as far back as 90 days. The connection drops now and then even when all is well, so reconnect every time it closes. Two open streams both receive every event, so handle each event once, by its id.
Webhooks carry the same events to your server instead.
Idempotency key
An idempotency key is a name you choose for one action, so a retried request does not do it twice. Send it in the Idempotency-Key header. Send the same request again with the same key and Mapier does not do it twice: you get the same commandId, with repeated: true. Leave the header off and every request is new, so a retry sends twice. Retries explains when a repeat is refused instead.
Version
Send x-mapier-version on every request. It pins the behavior your code is written against, so a change to the API never changes your integration on its own. Start on the newest version, 2026-12-01, as every example here does. Versions lists them all.