message.edit

Change the text of a message the line sent, within 15 minutes of sending it. The person sees it marked Edited.

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.

Honours Idempotency-Key. The message this platform stores is not changed: its text stays what was sent, and the new text is in your request and nowhere else.

Target

Name the message at target.messageId by the messageId its send's command frame carried, in the conversation at target.conversationId.

Prop

Type

Payload

Prop

Type

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 transport has not given the message an id: it is still being sent, it failed, or it is a rich link, which never gets one
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 from the message's own time, so an edit let through seconds before the window closes may still settle 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.

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" \
  -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": "cmd-11", "status": "queued", "disposition": "queued" }

Then a command frame, type: "message.edit":

  • succeeded once the line read the change back.
  • 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: re-read the thread, never retry blindly

The message may or may not have been edited. Look at the thread on the phone before you edit it again, and do not wait for a later settlement: this one may never be followed by another.

In test

The test line rehearses an edit on the relay's own executor, against the sandbox phone: it settles as a live line does, succeeded once read back, stale_target or invalid_target, and the refusals above are the same.

Errors

A command answers the one set of HTTP refusals POST /v1/commands/{type} publishes, so that table is the one to handle. What is particular to this type:

  • 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.

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

On this page