Edit a message

Works on
  • iMessage

Change the text of a message your line sent, within 15 minutes

POST/v1/commands/message.edit

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.

FieldTypeRequiredDescription
conversationIdstring (uuid)YesThe conversation the message is in. A group's is allowed.
messageIdstring (uuid)YesMapier's id for a message this line sent, the messageId its send's command event carried, never the channel's externalId.
lineIdstring (uuid)NoThe line to act from, as GET /v1/whoami lists it. Optional

Payload

FieldTypeRequiredDescription
textstringYesThe 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:

FieldreasonWhen
target.messageIdinvalid_targetThe message is not in that conversation, or was not sent from this line
target.messageIdnot_yet_addressableThe channel has not given the message an id: it is still being sent, or it failed
target.messageIdwindow_elapsedMore than 15 minutes have passed since the message was sent
payload.textBlank, 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

202 Accepted
{
  "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":

  • succeeded once the line confirmed the change.
  • failed with stale_target when the line no longer finds the message inside its window, or with invalid_target.
  • ambiguous with errorCode: "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_failed at target.messageId, payload.text or payload.<key>, above.
  • 404 unsupported_command with reason: not_on_channel on a line of any other channel.
  • 503 upstream_unavailable with reason: outbound_paused while the line's sending is paused.

Result codes you will see for this command: stale_target, invalid_target, moderation_unverified. See Error codes.

Guide