Unsend a message
- iMessage
Take back a message your line sent, within 2 minutes
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.
| 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
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:
reason | When |
|---|---|
invalid_target | The message is not in that conversation, or was not sent from this line |
not_yet_addressable | The channel has not given the message an id: it is still being sent, or it failed |
window_elapsed | More 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
{
"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":
succeededonce the line confirmed the change.failedwithstale_targetwhen 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.failedwithinvalid_target.ambiguouswitherrorCode: "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_failedattarget.messageIdorpayload.<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.