Unsend a message

Works on
  • iMessage

Take back a message your line sent, within 2 minutes

POST/v1/commands/message.unsend

Takes back a message this line sent. The person sees it gone from the conversation, marked Unsent. An unsend is allowed within 2 minutes of the message being sent.

Honors Idempotency-Key. Mapier keeps the message: reading the conversation back still returns it, with the text that was sent.

Body

Target

The same as message.edit: 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

None. Send {} or leave payload out. Any key is 422 validation_failed at payload.<key>, a payload.text included: new text is an edit.

What is refused before anything is sent

Each is 422 validation_failed at target.messageId, and nothing reaches the line:

reasonWhen
invalid_targetThe message is not in that conversation, or was not sent from this line
not_yet_addressableThe channel has not given the message an id: it is still being sent, or it failed
window_elapsedMore than 2 minutes have passed since the message was sent

The line checks the window again from the message's own time, so an unsend let through seconds before the window closes may still finish failed with stale_target. While the line's sending is paused an unsend 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.unsend \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: unsend-0192a7c4" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": {
      "conversationId": "a0000000-0000-4000-8000-000000000001",
      "messageId": "0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65"
    }
  }'

Response

202 Accepted
{
  "commandId": "0192b3e2-2b5d-7e31-9f62-4d8a0b3c7e21",
  "status": "queued",
  "repeated": false,
  "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d",
  "lineSelection": "reused_active_chat"
}

Then a command event, type: "message.unsend":

  • succeeded once the line confirmed the change.
  • failed with stale_target when the line no longer finds the message inside its window. An unsend that already worked, sent again under a new key, ends this way too: the message is no longer there to take back.
  • failed 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 be gone. Ask the person, or check the conversation on a device in it, before you send anything else about it. 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 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