RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
List ReportsResolve ReportsMute/Unmute UserBan/Unban UserAudit Logs
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

Ban / Unban User

Overview

Ban or unban a tenant chat user from Platform Moderation. A banned user is blocked from participating in chat according to your product rules, independent of any temporary mute.

Send banned: true to ban, or banned: falseto unban. On success, the API returns the user's updated moderation state, including isBanned.

When to use this endpoint?

Use Ban / Unban User when:

  • A moderator permanently (or until unban) blocks a report sender for serious policy violations.
  • Restoring access by unbanning a user (banned: false).
  • Acting from Platform → Moderation after reviewing List Reports (use messageSender._id as userId).
  • Preferring a lasting account action instead of (or after) a temporary Mute.

Part of the client Platform Moderation module. Ban and mute are independent — a user can be banned while still having a mutedUntil timestamp from a prior mute.

Request Fields

FieldRequiredDescription
bannedRequiredtrue to ban the user; false to unban.
PATCH{baseUrl}/api/{apiVersion}/client/moderation/users/:userId/ban

Authentication

Required (Bearer token)

Tenant-scoped

Yes (tenant DB — requires x-client-id)

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>Client Access Token with tenant admin privileges (Platform panel).
Content-Typeapplication/jsonRequired when sending a JSON body.
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true.

Path Parameters

ParameterExampleDescription
userId6a589b96cfa34ab66e35b2abThe chat user to ban or unban (for example messageSender._id from List Reports).

Request Payload

Ban

Set isBanned to true on the user.

json
{
  "banned": true
}

Unban

Clear the ban. Success data.isBanned becomes false.

json
{
  "banned": false
}

Success Response (HTTP 200 OK)

Returns the updated user moderation fields. In this ban example, isBanned is true. Any existing mutedUntil is returned as-is (ban does not clear a mute).

json
{
  "success": true,
  "message": "User banned successfully",
  "data": {
    "_id": "6a589b96cfa34ab66e35b2ab",
    "name": "Bad Actor",
    "email": "badactor@example.com",
    "isActive": true,
    "mutedUntil": "2026-07-16T09:03:29.501Z",
    "isBanned": true
  },
  "error": null
}

Response data fields

FieldDescription
_idUser id (same as path).
name / emailUser display identity.
isActiveAccount active flag (separate from ban state).
isBannedtrue when banned; false after unban.
mutedUntilExisting mute expiry if present — not cleared by ban/unban.

Common Errors

Ban fails when auth is invalid, the user id is missing, or banned is invalid.

HTTP 401 Unauthorized — No token

json
{
  "success": false,
  "message": "No token, authorization denied",
  "data": null,
  "error": "Unauthorized"
}

HTTP 403 Forbidden — Tenant admin required

json
{
  "success": false,
  "message": "Access denied: tenant admin privileges required",
  "data": null,
  "error": null
}

HTTP 404 Not Found — User missing

json
{
  "success": false,
  "message": "Entity not found",
  "data": null,
  "error": "Entity not found"
}
CodeReason
400 Bad RequestMissing or non-boolean banned field.
401 UnauthorizedAccess Token is missing, invalid, or expired.
403 ForbiddenTenant admin privileges required for Platform Moderation.
404 Not FoundNo user exists for the given userId.
500 Internal Server ErrorAn unexpected error occurred while updating ban state.

Best Practices

  • Confirm ban in the UI — it is a stronger action than mute.
  • After ban or unban, refetch List Reports so sender badges refresh.
  • You may still Resolve the related report (message_deleted or dismissed) in a separate step.
  • Use mute for temporary cooldowns; reserve ban for lasting blocks.
  • Check Audit Logs if you need a history of ban / unban actions.

Ban state updated

Bind data.isBanned in the moderation UI. Continue with Resolve Reports if the queue item is still pending, or review Audit Logs for the action trail.

PreviousMute/Unmute UserNextAudit Logs

On this page

OverviewWhen to use this endpoint?Request FieldsRequest HeadersPath ParametersRequest PayloadSuccess ResponseCommon ErrorsBest Practices