Flag, Mute & Ban

Overview

Stream provides moderation APIs for flagging content, muting users, banning users, and blocking users. These actions integrate with the moderation review queue and dashboard. All endpoints use the v2 moderation API and are available through Stream's server-side SDKs.


Flag

Flagging allows users or moderators to report content for review. Flagged content is automatically added to the moderation review queue. You can flag messages, users, activities, reactions, or any custom entity type.

Flag Content

Use the flag method to report an entity for moderation review. You can attach a reason, custom metadata, and a moderation payload containing the content to be reviewed.

client.moderation().flag(FlagRequest.builder()
    .entityType("stream:chat:v1:message")
    .entityID(messageId)
    .entityCreatorID(creatorId)
    .reason("spam")
    .custom(Map.of("user_comment", "This user is spamming the channel"))
    .userId(moderatorId)
    .build()).execute();

Request parameters

keyrequiredtypedescription
entity_typetruestringType of entity being flagged. Examples: stream:chat:v1:message, stream:user, stream:feeds:v2:activity, stream:feeds:v2:reaction, or any custom type.
entity_idtruestringUnique identifier of the entity being flagged.
entity_creator_idfalsestringUser ID of the entity creator.
reasonfalsestringReason for flagging. Use a slug or keyword for easy filtering.
customfalseobjectCustom metadata to attach to the flag.
moderation_payloadfalseobjectContent to be reviewed (texts, images, videos). Displayed on the dashboard.
user_idfalsestringUser ID of the person flagging (required for server-side usage).

Response

keytypedescription
item_idstringID of the review queue item created by the flag.

Flag a User

To flag a user rather than a message, set entity_type to stream:user and provide the target user's ID as entity_id.

client.moderation().flag(FlagRequest.builder()
    .entityType("stream:user")
    .entityID(targetUserId)
    .reason("harassment")
    .userId(moderatorId)
    .build()).execute();

Query Moderation Flags

Query flags with filtering, sorting, and pagination. This allows you to retrieve flags matching specific criteria.

var response = client.moderation().queryModerationFlags(QueryModerationFlagsRequest.builder()
    .filter(Map.of("entity_type", "stream:chat:v1:message"))
    .sort(List.of(SortParam.builder().field("created_at").direction(-1).build()))
    .limit(20)
    .build()).execute();

Request parameters

keyrequiredtypedescription
filterfalseobjectFilter conditions.
sortfalsearraySort parameters.
limitfalsenumberMaximum flags to return.
nextfalsestringPagination cursor.

Mute

Muting allows users to silence other users. Muted users' messages are still delivered via WebSocket but not via push notifications (APN/Firebase). Implementing UI logic for muted users (hiding or displaying differently) is left to the developer.

Mute User

Mute one or more users. You can optionally set a timeout after which the mute automatically expires.

client.moderation().mute(MuteRequest.builder()
    .targetIds(List.of("user_to_mute"))
    .userId(mutingUserId)
    .timeout(60)
    .build()).execute();

Request parameters

keyrequiredtypedescription
target_idstruearrayList of user IDs to mute.
user_idfalsestringUser ID of the person performing the mute.
timeoutfalsenumberMute duration in minutes. If not set, the mute has no expiration.

Unmute User

Remove a mute from one or more users.

client.moderation().unmute(UnmuteRequest.builder()
    .targetIds(List.of("user_to_unmute"))
    .userId(unmutingUserId)
    .build()).execute();

Ban

Banning prevents a user from posting messages. Users can be banned from a specific channel or from the entire app. Bans support timeouts (temporary bans), shadow banning, IP banning, and optional message deletion.

Ban User

Ban a user from the entire app. You can optionally specify a timeout for temporary bans, a reason, and whether to delete the user's messages.

client.moderation().ban(BanRequest.builder()
    .targetUserID("user_to_ban")
    .bannedByID(moderatorId)
    .reason("Repeated spam")
    .timeout(1440)
    .build()).execute();

Request parameters

keyrequiredtypedescription
target_user_idtruestringUser ID to ban.
banned_by_idfalsestringUser ID of the moderator performing the ban.
channel_cidfalsestringChannel CID for channel-scoped bans (e.g., messaging:general). Omit for app-wide bans.
reasonfalsestringReason for the ban.
timeoutfalsenumberBan duration in minutes. If not set, the ban is permanent.
shadowfalsebooleanWhen true, the user is shadow banned. Their messages are only visible to themselves.
ip_banfalsebooleanWhen true, also bans the user's last known IP address. Automatically applies a 30-day timeout unless overridden.
delete_messagesfalsestringDelete the user's messages. Values: soft (removes from client, retained on server) or hard (permanently deleted).

Channel-Scoped Ban

Ban a user from a specific channel by providing the channel_cid parameter. The user will still be able to use the rest of the app.

client.moderation().ban(BanRequest.builder()
    .targetUserID("user_to_ban")
    .bannedByID(moderatorId)
    .channelCID("messaging:general")
    .reason("Trolling in this channel")
    .timeout(60)
    .build()).execute();

Shadow Ban

Shadow banning allows a user to continue posting, but their messages are only visible to themselves. Other users will not see the shadow-banned user's messages. This is useful for handling disruptive users without alerting them.

client.moderation().ban(BanRequest.builder()
    .targetUserID("user_to_shadow_ban")
    .bannedByID(moderatorId)
    .reason("Disruptive behavior")
    .shadow(true)
    .build()).execute();

Unban User

Remove a ban from a user. For channel-scoped bans, provide the channel_cid parameter.

client.moderation().unban(UnbanRequest.builder()
    .targetUserID("user_to_unban")
    .unbannedByID(moderatorId)
    .build()).execute();

Block

Blocking allows a user to block another user. This is a server-side operation.

client.moderation().block(BlockRequest.builder()
    .targetUserID("user_to_block")
    .userId(blockingUserId)
    .build()).execute();

Bypass Moderation

Enable or disable moderation bypass for a specific user, allowing them to skip content moderation checks. This is a server-side only operation intended for trusted users whose content should not be subject to automated moderation.

client.moderation().bypass(BypassRequest.builder()
    .userId("trusted_user_id")
    .bypass(true)
    .build()).execute();

Request parameters

keyrequiredtypedescription
user_idtruestringUser ID to enable/disable bypass for.
bypasstruebooleantrue to enable bypass, false to disable.

User Moderation Report

Retrieve a comprehensive moderation report for a user, including their flags, bans, mutes, and other moderation actions.

var response = client.moderation().getUserModerationReport(GetUserModerationReportRequest.builder()
    .userId("user_123")
    .build()).execute();