Skip to main content
POST
/
v1
/
portal
/
chats
/
{chat_id}
/
ban
curl -X POST https://portal-api.7331.org/v1/portal/chats/42/ban \
  -H "Content-Type: application/json" \
  -b "psession=YOUR_SESSION" \
  -d '{"user_id": 7, "duration": 86400, "reason": "Repeated rule violations"}'
{
  "ok": true
}

Documentation Index

Fetch the complete documentation index at: https://docs.7331.org/llms.txt

Use this file to discover all available pages before exploring further.

Bans a user from a chat. The ban is stored in Redis with an optional TTL. If no duration is provided, the ban is permanent until lifted manually. Banning also removes the user from the chat’s DB membership, so they cannot rejoin a private chat via stored membership. Broadcasts a user:banned event to all clients in the chat — the banned user’s client is expected to leave on receipt. For an immediate server-side disconnect (while the user is online), use the room:kick Socket.IO event with ban: true instead. Authorization: Chat owner can always ban. For private chats, Admin+ can also ban. For public/official chats, any user who outranks the chat owner (via permission hierarchy) can ban. Hierarchy is also enforced against the target — you cannot ban someone at or above your permission level.
chat_id
integer
required
Chat ID.
user_id
integer
required
User ID of the user to ban. Cannot be your own user ID.
duration
integer
default:"0"
Ban duration in seconds. 0 for permanent. Maximum: 2592000 (30 days).
reason
string
Reason for the ban. Max 500 characters.

Response

ok
boolean
required
true if the user was banned.
curl -X POST https://portal-api.7331.org/v1/portal/chats/42/ban \
  -H "Content-Type: application/json" \
  -b "psession=YOUR_SESSION" \
  -d '{"user_id": 7, "duration": 86400, "reason": "Repeated rule violations"}'
{
  "ok": true
}
To ban and immediately remove an online user in one step, use the room:kick Socket.IO event with "ban": true. The REST endpoint is best for banning offline users or setting a ban without an immediate kick. To lift a ban, use Unban User from Chat.