Skip to main content

Overview

Baileys allows you to modify messages after sending them. You can:
  • Delete messages for everyone
  • Edit sent messages
  • Delete messages for yourself only (via chat modify)

Deleting Messages

Delete a message for everyone in the chat:

Delete Using Message Key

If you have the message key from a previous message:

Delete Received Messages

As a group admin, you can delete anyone’s message:
You can only delete messages for everyone within approximately 48 hours of sending. After that, you can only delete for yourself.

Editing Messages

Edit a previously sent message:

Edit Any Message Type

You can edit various message types:

Edit Using Stored Key

Message edits are limited to approximately 15 minutes after sending. The exact time limit may vary based on WhatsApp’s policies.

Protocol Details

Delete Message Protocol

When you delete a message, Baileys sends a protocol message:
This is handled automatically when you use:

Edit Message Protocol

Editing sends a protocol message with the updated content:
Baileys handles this when you use:

Delete for Yourself Only

To delete messages only on your device (not for everyone):
This removes the message from your chat history but doesn’t delete it for other participants. See Modifying Chats for more details.

Best Practices

1. Store Message Keys

2. Implement Message Store

3. Handle Edit Events

4. Validate Before Deleting

Error Handling

Limitations

Delete Limitations

  • Can only delete within ~48 hours of sending
  • Must be sent by you or (in groups) you must be admin
  • Cannot delete messages in newsletters (read-only)

Edit Limitations

  • Can only edit within ~15 minutes of sending
  • Can only edit your own messages
  • Edit history is visible to recipients (WhatsApp shows “edited” label)
  • Cannot edit media type (e.g., can’t change image to video)

Message Update Events

Listen for message modifications:

Examples from Source

Complete Example

Next Steps

Downloading Media

Learn to download media from messages

Message Options

Configure ephemeral and other options