Stream Chat
Integrating moderation in Stream Chat is a straightforward process that requires no code changes. You simply need to configure moderation policies through the dashboard, and Stream will automatically handle content moderation for your chat application. This guide will walk you through setting up moderation policies and monitoring flagged content through the Stream dashboard.
Configure Moderation Policy
A moderation policy is a set of rules that define how content should be moderated in your application. See Configuration for details on setting up moderation policies.
Auto Moderation on Message
Client side integration
A Chat UI SDK applies the configured policy to messages automatically. No client code is required.
Server side integration
If you are using the SendMessage API from server side, then by default messages will be skipped for moderation. You can enable moderation for messages by setting the force_moderation option to true.
force_moderation is server-side only and ignored when sent from a client-side SDK.
await client.Chat.SendMessageAsync(channelType, channelID, new SendMessageRequest
{
Message = new MessageRequest
{
Text = text,
UserID = sentBy,
},
ForceModeration = true,
});If moderation removes the message, SendMessage does not return an error. The message object has type error instead.
The moderation object in the response includes the action taken and detailed information about why the message was moderated. The example response is as following:
{
"message": {
"id": "2b56e00f-4149-465f-b1e7-62d892788f85",
"type": "error",
"text": "Message was blocked by moderation policies",
"moderation": {
"action": "remove",
"original_text": "F*** you motherf***er",
"text_harms": ["insult"],
"blocklists_matched": ["profanity-list"]
},
"user": {
"id": "little-lake-2",
"name": "little-lake-2",
...
},
"cid": "messaging:first",
"created_at": "2026-10-20T13:13:38.071535Z",
"updated_at": "2026-10-20T13:13:38.071535Z",
"shadowed": false,
...
},
"duration": "136.06ms"
}The moderation object contains the following fields:
| Field | Type | Description |
|---|---|---|
action |
string | keep, flag, mask, mask_flag, shadow, remove, bounce, bounce_flag, or bounce_remove. There is no severity field. |
original_text |
string | The original message text before moderation |
text_harms |
string[] | NLP or LLM text labels (for example ["insult"]) |
image_harms |
string[] | Labels from AI image moderation (e.g., ["nudity", "violence"]) |
blocklists_matched |
string[] | Names of blocklists that matched (e.g., ["profanity-list", "spam-words"]) |
The detailed moderation labels (text_harms, image_harms, blocklists_matched) are only included in server-side responses. Client-side responses only include action and original_text.
When a message is removed, no message.new WebSocket event is sent. Other users in the channel do not see it.
Policy keys
Chat looks up the most specific policy key, then falls back:
chat:messaging:channel_idfor one channelchat:messagingfor every channel of that typechatfor every chat channel
Poll text uses polls:default. See Moderate poll text.
User-Driven Actions
In addition to automated moderation, Stream's Chat SDK provides methods for users to take moderation actions against other users. These actions help maintain community standards by allowing users to report inappropriate behavior or content. For detailed information on effects of these actions, please check the documentation for Chat Moderation Tools. Here we cover some basic examples on how to use these actions.
Flag User
Users can flag another user with a reason. This will trigger a review in the moderation dashboard.
If you are using Chat UI SDK, users can flag the user from user actions menu.
If you have your own custom UI, you can use the following API to flag the user:
var response = await client.FlagAsync(new FlagRequest
{
EntityType = "stream:user",
EntityID = "user_id",
Reason = "reason",
});Flag Message
Users can flag a message, which will trigger a review in the moderation dashboard.
If you are using Chat UI SDK, users can flag the message from message actions menu.
If you have your own custom UI, you can use the following API to flag the message:
var response = await client.FlagAsync(new FlagRequest
{
EntityType = "stream:chat:v1:message",
EntityID = "message_id",
Reason = "reason",
});Ban User
A user with moderator permissions can ban a user from the chat. For more details, please check the documentation for Banning Users.
var response = await client.BanAsync(new BanRequest
{
TargetUserID = "target_user_id",
BannedByID = "user_id", // User ID who is banning the user.
});Unban User
A user with moderator permissions can unban a user from the chat.
var response = await client.UnbanAsync(new UnbanRequest
{
TargetUserID = "target_user_id",
});