---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/restore
title: Restore messages
updated_at: 2026-06-19T11:35:22.768Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Restore messages

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

:::note Requires Message Persistence
Enable [Message Persistence](https://youtu.be/qLMtbINWGig) and **Enable Delete-From-History** in the [Admin Portal](https://admin.pubnub.com/).
:::

### Method signature

This method has the following signature:

```csharp
message.Restore()
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `Task<ChatOperationResult>` | Returned `Task` that you can `await` to get the result of the restore operation. |

### Sample code

Restore a previously soft deleted message with the `16200000000000001` timetoken.

```csharp
using System.Linq;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// reference the "channel" object
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.Log("Channel 'support' not found.");
    return;
}
var channel = channelResult.Result;
Debug.Log($"Found channel with name {channel.Name}");

// invoke the method on the "channel" object to get message history
var messagesResult = await channel.GetMessageHistory(
    "16200000000000000", 
    "16200000000000001", 
    1
);
if (messagesResult.Error || !messagesResult.Result.Any())
{
    Debug.Log("Message not found.");
    return;
}

// Find the specific message with the given timetoken
var message = messagesResult.Result[0];

// Restore the message
await message.Restore();
```