Actions60
- User Actions
- Channel Actions
- Accept Invite
- Add Members
- Add Moderators
- Archive
- Ban User
- Create
- Delete
- Delete File
- Delete Image
- Demote Moderators
- Disable Slow Mode
- Enable Slow Mode
- Get Config
- Hide
- Invite Members
- Mark Read
- Mark Unread
- Mute
- Mute Status
- Pin
- Query Channels
- Query Members
- Reject Invite
- Remove Members
- Send Action
- Send File
- Send Image
- Show
- Stop Watching
- Truncate
- Unarchive
- Unban User
- Unmute
- Unpin
- Update
- Watch
- Message Actions
- Moderation Actions
Overview
The "Ban User" operation under the "Channel" resource allows you to ban a specific user from a particular chat channel in a Stream Chat environment. This is useful for moderating group chats, team channels, or messaging channels by restricting access to users who violate community guidelines or rules.
Typical scenarios include:
- Temporarily banning a disruptive user from a team channel.
- Banning a user from a livestream broadcast channel due to inappropriate behavior.
- Enforcing moderation policies in 1-on-1 messaging channels.
For example, you might ban a user from the "team-alpha" channel for 60 minutes with a reason like "Spamming messages".
Properties
| Name | Meaning |
|---|---|
| Channel Type | The type of the channel. Common options: "messaging" (1-on-1 chats), "team" (group channels), "livestream" (broadcast channels) |
| Channel ID | Unique identifier for the channel (e.g., "general", "random", "team-alpha"). Combined with type to form CID. Required. |
| Target User ID | The ID of the user to ban from the channel. Required. |
| Ban Reason | Optional text describing the reason for the ban. |
| Ban Timeout (Minutes) | Duration of the ban in minutes. Minimum value is 1. Default is 60 minutes. |
Output
The node outputs a JSON object representing the result of the ban operation. This typically includes details about the banned user and the ban status as returned by the Stream Chat API.
Example output JSON structure (simplified):
{
"user": {
"id": "targetUserId",
"banned": true,
"ban_expires": "timestamp"
},
"reason": "Ban Reason",
"timeout": 60
}
No binary data is produced by this operation.
Dependencies
- Requires an active Stream Chat API credential configured in n8n with sufficient permissions to perform channel moderation actions.
- The node uses the Stream Chat server-side client SDK to execute the ban operation.
- Proper API key and secret must be set up in n8n credentials for authentication.
Troubleshooting
Common issues:
- Invalid or missing Channel ID or Target User ID will cause errors.
- Insufficient permissions on the API key may result in authorization errors.
- Providing a ban timeout less than 1 minute will be rejected.
- Network or API downtime can cause request failures.
Error messages:
"Unsupported operation: channel.banUser": Indicates the operation is not recognized; verify the Resource and Operation selections."Error in channel.banUser operation": General error wrapper; check the inner message for specifics such as invalid parameters or permission issues."User not found"or"Channel not found": Verify that the provided IDs exist in your Stream Chat app.
Resolution tips:
- Double-check all required fields are filled correctly.
- Ensure the API credentials have channel moderation rights.
- Increase the ban timeout if needed or set it according to your policy.
- Review Stream Chat API documentation for rate limits or additional constraints.