On this page

Restore messages

restore() recovers soft-deleted messages and their attached files. Hard-deleted messages cannot be restored.

Requires Message Persistence

Enable Message Persistence and Enable Delete-From-History in the Admin Portal.

Method signature

icon

Under the hood


This method has the following signature:

1message.restore()
2: Promise<Message>

Input

This method doesn't take any parameters.

Output

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

Sample code

Restore a previously soft deleted message with the 16200000000000001 timetoken.

1// reference the "message" object
2const { messages } = await channel.getHistory({
3 startTimetoken: "16200000000000000",
4 endTimetoken: "162000000000000001"
5})
6const message = messages[0]
7// soft delete this message
8await message.delete({
9 soft: true
10})
11
12// restore the deleted message
13await message.restore()
Last updated on