Text
- iMessage
Send a text message, and add formatting, a subject or a quoted reply
A text is a message.send whose payload has kind: "text" and the words in text. It goes into any conversation, and to someone new where the channel lets your agent write first.
Send a text
This reply goes into a conversation the person started. To write to someone new, name them at target.recipientExternalId instead, and check who can write first.
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": { "conversationId": "a0000000-0000-4000-8000-000000000001" },
"payload": { "kind": "text", "text": "Yes, by the window." }
}'{
"commandId": "0192b3e1-…",
"status": "queued",
"repeated": false,
"lineId": "0192a7b0-…",
"lineSelection": "reused_active_chat",
"channel": "imessage"
}Keep commandId. Its result on the stream says whether the text went out.
Format the text
On iMessage, textFormatting draws parts of the text bold, italic, underlined or struck through, plays an animation on them, or mentions the person. Each range is start and length in UTF-16 code units of text, with at least one of styles, effect and mention:
{
"kind": "text",
"text": "Your table is ready.",
"textFormatting": [{ "start": 14, "length": 5, "styles": ["bold"] }]
}A mention's range covers the name as you wrote it in text, and its value is the person's address:
{
"kind": "text",
"text": "Thanks, Sam!",
"textFormatting": [{ "start": 8, "length": 3, "mention": "+14155550100" }]
}The styles are bold, italic, underline and strikethrough. The twelve animations are bounce, stretch, squish, scaleRipple, big, bloom, somersault, nod, shake, jitter, small and explode. A mention works only in a one-to-one conversation: its value is that person's address, and its range covers their name, never their address. A mention in a group chat is refused.
subject adds a bold line above the text, such as an order number. A screen or bubble animation is an effect. Formatting, a subject and an effect go only into a conversation the person has written in, or a group chat.
On WhatsApp, write the formatting into the text: *bold*, _italic_ and ~strikethrough~. Set platform.whatsapp.previewUrl to true to show a preview of the first link in the text.
| Channel | Markup and mentions in the text |
|---|
Reply to a message
Name the message you answer at target.replyToMessageId, the messageId of its message.received event. The line quotes it where it can. Where it cannot, the send is refused with a 422 at that key, and nothing is sent unquoted.
{
"conversationId": "a0000000-0000-4000-8000-000000000001",
"from": "+14155550100",
"text": "Which one is the 7pm booking?",
"messageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22"
}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: reply-to-0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22" \
-H "x-mapier-version: 2026-12-01" \
-d '{
"target": {
"conversationId": "a0000000-0000-4000-8000-000000000001",
"replyToMessageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22"
},
"payload": { "kind": "text", "text": "The 7pm one is table 4, by the window." }
}'Make the Idempotency-Key from the message you answer. If the same event reaches you twice, the second send is the same command, not a second reply. See Retries.
Limits
| Channel | Longest text |
|---|---|
| iMessage | 65,536 bytes of UTF-8 |
| 4,096 characters |
On iMessage the limit is bytes, not characters: most accented letters take two bytes, Chinese, Japanese and Korean take three, and an emoji four or more. The whole request body is at most 65,536 bytes on every channel. Split long text into several messages.
A first message to someone new on iMessage carries plain text only, at most 16,384 bytes, sent to a phone number.
| Channel | How fast you can send |
|---|
When a text fails after sending
A text the channel refuses ends as a failed result, with a failureClass that says what to do. Results and delivery lists every class.
Receive a text
An incoming text arrives as a message.received event with the words in text. Incoming messages shows the whole event.
Errors you may see
Each of these comes back at once, and nothing is sent.
| Error | Means | Fix |
|---|---|---|
403 recipient_not_allowed | This person cannot get messages from you yet | Check who can write first |
413 payload_too_large | The request body is over 65,536 bytes | Split the text into several messages |
422 validation_failed, invalid_text | The text is blank, or too long for a first message | Send shorter text |
422 validation_failed, conversation_not_confirmed | Formatting or a subject went to someone new | Send plain text first |