Skip to content

Working with methods to edit and delete messages#

Beta version

The functionality is in beta mode. Features are subject to change and may also work unstably. There may be additional charges for functionality in the future.

Recommendations for working with editable and deleted messages:

  1. Instance setup
  2. Working with editing messages method
  3. Working with deleting messages method

1. Instance setup#

To work with notifications about edited and deleted messages enable the editedMessageWebhook and deletedMessageWebhook settings on the instance (by default the settings are disabled).

Choose a way to enable the settings:

  1. In the console settings;

  2. Via SetSettings method:

    "editedMessageWebhook":"yes",
    "deletedMessageWebhook":"yes"  
    

  3. Via partners' method CreateInstance:

    "editedMessageWebhook":"yes",
    "deletedMessageWebhook":"yes"  
    

2. Working with editing messages method#

Method EditMessage#

When calling the EditMessage method, you will receive idMessage in response - the identifier of the edited message.

You can use it to receive a notification about the result of editing, as well as track which user edited the message (if there are several operators in the system).


Processing incoming notifications#

When editing a message, a notification of type editedMessageWebhook is generated.

Notification Examples

Example notification of type editedMessageWebhook for an incoming message:

{
    "typeWebhook": "incomingMessageReceived",
    "instanceData": {
        "idInstance": 1101000001,
        "wid": "79876543210@c.us",
        "typeInstance": "whatsapp"
    },
    "timestamp": 1738566656,
    "idMessage": "3U28ABACVPDF65C8B28",
    "senderData": {
        "chatId": "71234567890@c.us",
        "chatName": "John",
        "sender": "71234567890@c.us",
        "senderName": "John",
        "senderContactName": "John Doe"
    },
    "messageData": {
        "typeMessage": "editedMessage",
        "editedMessageData": {
            "textMessage": "Edited message",
            "stanzaId": "3PEAD8EDB7A9D438FF5E"
        }
    }
}

Example of notification type editedMessageWebhook for an outgoing message:

{
    "typeWebhook": "outgoingMessageReceived", / "outgoingAPIMessageReceived",
    "instanceData": {
        "idInstance": 1101000001,
        "wid": "79876543210@c.us",
        "typeInstance": "whatsapp"
    },
    "timestamp": 1738566656,
    "idMessage": "C9801E522F8BFE8091215CAD1FC25D87",
    "senderData": {
        "chatId": "71234567890@c.us",
        "chatName": "Jane",
        "sender": "79876543210@c.us",
        "senderName": "John",
        "senderContactName": "John Doe"
    },
    "messageData": {
        "typeMessage": "editedMessage",
        "editedMessageData": {
            "textMessage": "Edited message",
            "stanzaId": "85E55C3B4AEC6FA1281ADCFF9E078E32"
        }
    }
}

The textMessage field contains the new message text.
The stanzaId field contains the original text of the message that was edited.

We recommend that you only process the notifications you need.

The handler service must find the mandatory typeWebhook field, and depending on its type, process or reset the notification. This way, only the selected event types will be processed, and incorrect instance settings or new API releases will not disrupt your integration.


Working through journals#

When working through journalging methods, you can determine whether a message has been edited by the isEdited: true field.

Example Journal Entries

Example of incoming edited message:

{
    "type": "incoming",
    "idMessage": "3ABB6C1B73334C9741F4",
    "timestamp": 1739539803,
    "typeMessage": "extendedTextMessage",
    "chatId": "70000000012@c.us",
    "textMessage": "Hello!",
    "extendedTextMessage": {
    "text": "Hello!",
    "description": "",
    "title": "",
    "previewType": "None",
    "jpegThumbnail": "",
    "forwardingScore": 0,
    "isForwarded": false
    },
    "senderId": "70000000012@c.us",
    "senderName": "Vasilisa the Wise",
    "senderContactName": "Vasilisa",
    "deletedMessageId": "",
    "editedMessageId": "3AC57AE5BB0784C80047",
    "isEdited": true,
    "isDeleted": false
}

Example of outgoing edited message:

{
    "type": "outgoing",
    "idMessage": "BAE5143000000000",
    "timestamp": 1706761225,
    "typeMessage": "extendedTextMessage",
    "chatId": "70000000012@c.us",
    "textMessage": "Hello",
    "extendedTextMessage": {
    "text": "Hello",
    "description": "",
    "title": "",
    "previewType": "None",
    "jpegThumbnail": "",
    "forwardingScore": 0,
    "isForwarded": false
    },
    "statusMessage": "read",
    "sendByApi": true, // false,
    "deletedMessageId": "",
    "editedMessageId": "3AC57AE5BB0784C80047",
    "isEdited": true,
    "isDeleted": false
}

To update the chat history, we recommend identifying messages that were received or sent in the last 15 minutes (the permissible time for editing messages), and updating them every 10-15 seconds using one of the methods:


Please note#

  1. Notifications about edited messages come for all message types: incoming, sent from API and sent from phone.

    Depending on this, typeWebhook will contain

  2. For edited messages, as well as for sent messages, notifications of the type outgoingMessageStatus are generated.

  3. In the journals, edited messages will have the type outgoing or incoming depending on who edited the message.

    The journal will only contain the edited message and the stanzaId field containing the identifier of the original message.

  4. The message editing method works through the message queue.

    Therefore, if a mailing was performed on the instance and a queue was formed, then editing will not occur immediately, but only after the previous messages in the queue have been processed.

  5. If the system does not process the edited message within 15 minutes from the moment the original message was written, then the message will not be changed.

    A request to edit a message will generate a notification with an error (status failed).
    The description field will indicate the reason for the error.

    Notification example
    {
    "typeWebhook": "outgoingMessageStatus",
    "chatId": "79001234567@c.us",
    "instanceData": {
    "idInstance": 1101000001,
    "wid": "79001234567@c.us",
    "typeInstance": "whatsapp"
    },
    "timestamp": 1739426932,
    "idMessage": "BAE56687379D581D",
    "status": "failed",
    "description": "15 minute editing time gap has been expired",
    "sendByApi": true
    }
    
  6. When calling the method with an incorrectly specified idMessage, a notification with an error (failed status) will be generated.
    The description field will indicate the reason for the error.

3. Working with deleting messages method#

Method DeleteMessage#

When calling the DeleteMessage method, you will receive status code 200 and an empty body in response.

The system generates an identifier for the message deletion event.
This identifier will be specified in the notification for the message deletion event.


Processing incoming notifications#

When a message is deleted, a notification of type deletedMessageWebhook is generated.

Notification Examples

Example of notification type deletedMessageWebhook for an incoming message:

    {
    "typeWebhook": "incomingMessageReceived",
    "instanceData": {
    "idInstance": 1101000001,
    "wid": "71231234567@c.us",
    "typeInstance": "whatsapp"
    },
    "timestamp": 1733146115,
    "idMessage": "10ECA1E0D26FAB972C24C56C8285ACAB",
    "senderData": {
    "chatId": "71234567890@c.us",
    "chatName": "Vasilisa",
    "sender": "71234567890@c.us",
    "senderName": "Ivan",
    "senderContactName": "Ivan Tsarevich"
    },
    "messageData": {
        "typeMessage": "deletedMessage",
        "deletedMessageData": {
        "stanzaId": "84514217EF972039FC3F68A53C196306" // ID of the message that was deleted
        }
    }
}

Example of notification type deletedMessageWebhook for a sent message:

{
    "typeWebhook": "outgoingMessageReceived", / "outgoingAPIMessageReceived",
    "instanceData": {
    "idInstance": 1101000001,
    "wid": "71231234567@c.us",
    "typeInstance": "whatsapp"
    },
    "timestamp": 1733146115,
    "idMessage": "C9801E522F8BFE8091215CAD1FC25D87",
    "senderData": {
    "chatId": "71234567890@c.us",
    "chatName": "Vasilisa",
    "sender": "71231234567@c.us",
    "senderName": "Ivan",
    "senderContactName": "Ivan Tsarevich"
    },
    "messageData": {
        "typeMessage": "deletedMessage",
        "deletedMessageData": {
        "stanzaId": "85E55C3B4AEC6FA1281ADCFF9E078E32" // id of the message that was deleted
        }
    }
}

The stanzaId field contains the identifier of the message that was deleted.

We recommend that you only process the notifications you need.

The handler service must find the mandatory typeWebhook field, and depending on its type, process or reset the notification. This way, only the selected event types will be processed, and incorrect instance settings or new API releases will not disrupt your integration.


Working through journals#

When working through journals methods, you can determine whether a message has been deleted by the isDeleted: true field.

Examples of journal entries

Example of an incoming deleted message:

{
    "type": "incoming",
    "idMessage": "3ABB6C1B73334C9741F4",
    "timestamp": 1739539803,
    "typeMessage": "textMessage",
    "chatId": "70000000012@c.us",
    "textMessage": "Hello!",
    "senderId": "70000000012@c.us",
    "senderName": "Vasilisa the Wise",
    "senderContactName": "Vasilisa",
    "deletedMessageId": "3AC57AE5BB0784C80047",
    "editedMessageId": "",
    "isEdited": false,
    "isDeleted": true
}

Example of an outgoing deleted message:

{
    "type": "outgoing",
    "idMessage": "E4E0E381ACE74B5845437A8F0E365D75",
    "timestamp": 1739538875,
    "typeMessage": "textMessage",
    "chatId": "70000000012@c.us",
    "textMessage": "Hello!",
    "statusMessage": "read",
    "sendByApi": true, // false,
    "deletedMessageId": "7863F3285595F3A296FEF8C6C386871F",
    "editedMessageId": "",
    "isEdited": false,
    "isDeleted": true
}

To keep your chats up-to-date, we recommend updating them every 10-15 seconds using one of the methods:


Please note#

  1. Notifications about deleted messages come for all message types: (incoming, sent from API and sent from phone).

    Depending on this, typeWebhook will contain:

  2. For deleted messages, as well as for sent messages, notifications of the type outgoingMessageStatus are generated.

  3. In the journals, deleted messages will have the type outgoing or incoming depending on who deleted the message.

    The journal will contain an entry about the message deletion and the stanzaId field containing the identifier of the deleted message.

  4. The journal will record all message deletion events:

    • who deleted the message - senderId,
    • in which chat was the message deleted - chatId,
    • when was the message deleted - timestamp.

    The original message is not deleted from the journal, it changes the field to isDeleted: true.