Restore messages

If you delete a message, you can restore its content together with the attached files using the restore() method.

This is possible, however, only if the message you want to restore was soft deleted (the soft parameter was set to true when deleting it). Hard deleted messages cannot be restored as their data is no longer available in Message Persistence.

Requires Message Persistence configuration

To manage messages, you must enable Message Persistence for your app's keyset in the Admin Portal and mark the Enable Delete-From-History option.

Method signature

icon

Under the hood


This method has the following signature:

message.restore()
: Promise<Message>

Input

This method doesn't take any parameters.

Output

TypeDescription
Promise<Message>Object returning the restored Message object.

Basic usage

Restore a previously soft deleted message with the 16200000000000001 timetoken.

// reference the "message" object
const message = await channel.getHistory({
startTimetoken: "16200000000000000",
endTimetoken: "162000000000000001"
})
// soft delete this message
await message.delete({
soft: true
})

// restore the deleted message
await message.restore()
Last updated on