Edit & Delete messages

Learn how to edit and delete WhatsApp messages using Unipile API.

Edit a message

To edit a message, use Modify a Message method. Provide the ID of the message to edit along the new text content.

❗️

Provider limitations

Be aware of time and role limitations imposed by WhatsApp when editing messages. Unipile may respond successfully without actually editing the message if limitations are not respected.

const { data, error } = await messagingApi.modifyMessage({
  path: {
    account_id: "acc_123456789",
    chat_id: "chat_id",
    message_id: "message_id",
  },
  body: {
    text: "Updated message content",
  },
});
messaging_api.modify_message(
    "chat_id",
    "message_id",
    "acc_123456789",
    {"text": "Updated message content"},
)
curl --request POST \
     --url https://api.unipile.com/v2/account_id/chats/chat_id/messages/message_id/modify \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "text": "Updated message content"
}
'

Delete a message

In WhatsApp applications, you can delete messages for everyone or for yourself.

To delete a message for everyone, use Delete a Message method and provide the ID of the message to delete.

  • Delete a message for yourself is not supported.
  • Delete a message from another user as a group admin is not supported.
❗️

Provider limitations

Be aware of time and role limitations imposed by WhatsApp when deleting messages for everyone. Unipile may respond successfully without actually deleting the message if limitations are not respected.

const { error } = await messagingApi.deleteMessage({
  path: {
    account_id: "acc_123456789",
    chat_id: "chat_id",
    message_id: "message_id",
  },
});
messaging_api.delete_message(
    "chat_id",
    "message_id",
    "acc_123456789",
)
curl --request DELETE \
     --url https://api.unipile.com/v2/account_id/chats/chat_id/messages/message_id

To be notified when a message is deleted from a chat, setup a Webhook that listen for message.delete events. It works for messages deleted for yourself from other devices, and any messages deleted for everyone.
It won't be sent for messages deleted due to a deleted chat.


Be notified about a delete and edited message

Configure a webhook that listen for message.delete and message.update to receive events of delete /edited messages.