---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/moderation
title: Report offensive messages
updated_at: 2026-05-28T15:00:35.399Z
---

> 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


# Report offensive messages

Users can report offensive messages directly from your app. Reported messages publish to `PUBNUB_INTERNAL_MODERATION_{channel_id}` and emit [report events](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/custom-events#chat-events).

Add custom logic using [emitted events](#listen-to-report-events) to handle reported messages (e.g., [delete them](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/delete)).

:::note Message Persistence
Enable Message Persistence in the [Admin Portal](https://admin.pubnub.com/).
:::

## Flag/Report messages

`Report()` flags a message for admin review. Reports publish to `PUBNUB_INTERNAL_MODERATION_{channel_id}` (e.g., reporting on `support` sends to `PUBNUB_INTERNAL_MODERATION_support`).

### Method signature

This method takes the following parameters:

```csharp
message.Report(string reason)
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| reason | string | Yes |  | Reason for reporting/flagging a given message. |

#### Output

An awaitable `Task<ChatOperationResult>`.

### Sample code

Report the last message on the `support` channel as offensive.

```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;
}
// get the "support" channel
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.Log("Support channel not found.");
    return;
}
var channel = channelResult.Result;

Debug.Log($"Found channel with name {channel.Name}");

// retrieve the message history with the desired count
var messageHistoryResult = await channel.GetMessageHistory(null, null, 1);
if (messageHistoryResult.Error)
{
    Debug.Log("Could not retrieve message history.");
    return;
}

// get the last message from the returned list
var lastMessage = messageHistoryResult.Result.FirstOrDefault();

// report the last message if it exists
if (lastMessage != null)
{
    await lastMessage.Report("This is insulting!");
    Debug.Log("Reported the last message in the support channel.");
}
else
{
    Debug.Log("No messages found in the channel history.");
}
```

## Listen to Report events

`StreamReportEvents()` monitors report events for moderation dashboards. Use `OnMessageReported` to handle report updates.

:::tip Events documentation
To read more about the events of type `Report`, refer to the [Chat events](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/custom-events#events-for-reported-messages) documentation.
:::

:::tip Method naming
Earlier versions used `SetListeningForReportEvents()` to enable streaming. This method has been superseded by `StreamReportEvents()`, though it remains available for backward compatibility.
:::

### Method signature

These methods take the following parameters:

* StreamReportEvents() 1channel.StreamReportEvents(bool stream)
* OnMessageReported - Event signature 1// event on the Channel entity — enabled by StreamReportEvents()2public event Action<MessageReport> OnMessageReported;3// needs a corresponding event handler4void EventHandler(MessageReport report)

#### Input

| Parameter | Required in `StreamReportEvents()` | Required in `OnMessageReported` | Description |
| --- | --- | --- | --- |
| `stream`Type: `bool`Default: n/a | Yes | n/a | Whether to start (`true`) or stop (`false`) listening to report events on the channel. Events are sent to the `PUBNUB_INTERNAL_MODERATION_{channel_id}` channel. |
| `report`Type: [MessageReport](https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/event#typed-event-data)Default: n/a | No | Yes | Typed report data containing the flagged message text, reason, timetoken, channel ID, and reporter's user ID. |

#### Output

These methods don't return a value. Report event updates are delivered through the `OnMessageReported` event handler.

### Sample code

Print a notification for an offensive message reported on the `support` channel.

```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;
}
var channelResult = await chat.GetChannel("support");
if(channelResult.Error){
    Debug.Log("Couldn't find the support channel!");
    return;
}
var channel = channelResult.Result;
channel.StreamReportEvents(true);
channel.OnMessageReported += reportEvent => 
{
    Debug.Log("Message reported on the support channel!");
};
```