Quickstart

Send your first message with the Mapier messaging API. Text your line, such as an iMessage number, then reply from the API

Access to Mapier is by approval. New to Mapier? Book a call and Mapier sets up your account during the call. If someone invited you, the invitation is the approval.

Before you start, you need a line in the console, such as an iMessage number, a WhatsApp number. No line yet? Connect a line.

Create an API key

Create one on the Keys page. It is shown once.

export MAPIER_API_KEY="mp_live_…"

Text your line

Open a second terminal and leave this running. Incoming messages arrive here, and so does every command's result, whatever events= asks for.

export MAPIER_API_KEY="mp_live_…"
curl -N "https://api.mapier.ai/v1/response_stream?events=message.received" \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "x-mapier-version: 2026-12-01" \
  -H "Accept: text/event-stream"
Stream output
retry: 3000
: connected

A : ping line follows every 25 seconds. It means the connection is alive.

Then send your line a message:

ChannelHow to message your line
iMessageText it from your phone
WhatsAppMessage it on WhatsApp

The message arrives on the stream:

Stream output
id: 0192…
event: message.received
data: {"id":"0192…","type":"message.received","occurredAt":"…","data":{"conversationId":"a000…0001","lineId":"…","from":"+14155550142","text":"Is this real?","attachments":[],…}}

Copy the conversationId.

Reply

The reply names only the conversation. Mapier sends it from the same line, on the same channel.

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: first-reply" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": { "conversationId": "a000…0001" },
    "payload": { "kind": "text", "text": "Hi! This came from the Mapier API." }
  }'
202 Accepted
{
  "commandId": "…",
  "status": "queued",
  "repeated": false,
  "lineId": "…",
  "lineSelection": "reused_active_chat",
  "channel": "imessage"
}

202 means Mapier accepted the request. The result follows on the stream:

Stream output
id: 0192…
event: command
data: {"commandId":"…","type":"message.send","status":"succeeded","messageId":"…","conversationId":"a000…0001","lineId":"…"}

succeeded means the channel now has the message. It lands on your phone.

A retry with the same Idempotency-Key never sends twice. Leave the header off and every request is new, so two requests with no header are two messages. Retries explains.

Sent is not delivered

Delivered and read arrive later, as their own events. The stream sends them once you add receipts to events: ?events=message.received,receipts. Results and delivery explains each status.

Which receipts follow depends on the channel:

ChannelReceipts after succeeded
iMessageDelivered and read
WhatsAppDelivered and read

Next

Connect another line on iMessage or WhatsApp. Your code does not change.