Edit and unsend

Works on
  • iMessage

Change or take back a message your line sent, and hear when a person does

Edit a message changes the text of a message your line sent. Unsend a message takes it back. Both name the message by its conversationId and messageId, from the send's result.

Edit a message

curl -X POST https://api.mapier.ai/v1/commands/message.edit \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: edit-0192b3e1" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "messageId": "0192b3e1-6a02-7e11-8c4d-2b9f7e3a5d22" },
    "payload": { "text": "Your table is ready at 8." }
  }'

Unsend a message

Send message.unsend with the same target and no payload.

Limits

On iMessage, an edit or unsend works only inside Apple's window after the message was sent. The copy Mapier keeps is not changed: the conversation's history still shows the first text, and an unsent message stays in it.

When an edit fails after sending

An edit or unsend that names a message the line no longer finds inside its window ends as a failed result with errorCode: "stale_target". A result of ambiguous means the line could not tell whether the message changed. Do not retry it; if it matters, send a short correction as a new message.

Hear when a person edits or unsends

A person's edit or unsend arrives as a message.edited or message.unsent event, only if you ask for it: open the stream with ?events=moderation, or subscribe a webhook to the events by name.

Errors you may see

Each of these comes back at once, and nothing is sent.

ErrorMeansFix
422 validation_failed, invalid_targetThe message is not in that conversation, or not from this lineCheck the messageId
422 validation_failed, not_yet_addressableThe message is still being sent, or failedWait for its result
422 validation_failed, window_elapsedToo long since the message was sentSend a correction as a new message
404 unsupported_command, not_on_channelThe line's channel does not edit or unsendSend a correction as a new message

Next