Edit a message
- iMessage
Change the text of a message your line sent, within 15 minutes
Changes the text of a message this line sent. The person sees the new text in place, marked Edited. An edit is allowed within 15 minutes of the message being sent.
Honors Idempotency-Key. Mapier keeps the message's original text: reading the
conversation back returns the text as first sent, and the new text is only in
your request.
Body
Target
Name the message at target.messageId by the messageId its send's command
event carried, in the conversation at target.conversationId.
| Field | Type | Required | Description |
|---|---|---|---|
conversationId | string (uuid) | Yes | The conversation the message is in. A group's is allowed. |
messageId | string (uuid) | Yes | Mapier's id for a message this line sent, the messageId its send's command event carried, never the channel's externalId. |
lineId | string (uuid) | No | The line to act from, as GET /v1/whoami lists it. Optional |
Payload
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The message's new text. Not blank, at most 65,536 bytes as UTF-8. |
What is refused before anything is sent
Each is 422 validation_failed, and nothing reaches the line:
| Field | reason | When |
|---|---|---|
target.messageId | invalid_target | The message is not in that conversation, or was not sent from this line |
target.messageId | not_yet_addressable | The channel has not given the message an id: it is still being sent, or it failed |
target.messageId | window_elapsed | More than 15 minutes have passed since the message was sent |
payload.text | Blank, or over 65,536 bytes | |
payload.<key> | Any key but text |
The window is measured from when the message was sent. The line checks it again
when it runs the edit, so an edit let through seconds before the window closes
may still finish failed with stale_target.
While the line's sending is paused an edit is refused at once,
503 upstream_unavailable with reason: outbound_paused, rather than held
past its window.
Example request
curl https://api.mapier.ai/v1/commands/message.edit \
-H "Authorization: Bearer $MAPIER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-2481-shipped-fix" \
-H "x-mapier-version: 2026-12-01" \
-d '{
"target": {
"conversationId": "a0000000-0000-4000-8000-000000000001",
"messageId": "0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65"
},
"payload": { "text": "Your order shipped. It arrives Thursday." }
}'Response
{
"commandId": "0192b3e2-1a4c-7d20-8e51-3c7f9a2b6d10",
"status": "queued",
"repeated": false,
"lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d",
"lineSelection": "reused_active_chat"
}Then a command event, type: "message.edit":
succeededonce the line confirmed the change.failedwithstale_targetwhen the line no longer finds the message inside its window, or withinvalid_target.ambiguouswitherrorCode: "moderation_unverified"when the line could not prove what happened.
moderation_unverified: check before you retry
The message may or may not have been edited. Ask the person, or check the conversation on a device in it, before you edit it again. Do not wait for a later result: none may follow.
Errors
Every command can return the errors listed under How commands work › Errors. Specific to this command:
422 validation_failedattarget.messageId,payload.textorpayload.<key>, above.404 unsupported_commandwithreason: not_on_channelon a line of any other channel.503 upstream_unavailablewithreason: outbound_pausedwhile the line's sending is paused.
Result codes you will see for this command: stale_target,
invalid_target, moderation_unverified. See Error codes.