RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
CreateListGet by IDUpdateDelete
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

List Custom Roles

Overview

Retrieve a paginated list of roles for your tenant — both built-in system roles (Admin, User) and custom roles you created in the client Platform.

Use this endpoint to power the Custom Roles table, role pickers when editing users, and search for roles by name or slug.

When to use this endpoint?

Use List Custom Roles when:

  • Loading Platform → Custom Roles for the admin roles table.
  • Filling a role dropdown when creating or updating a Platform user.
  • Searching roles by name or slug with pagination.
  • Distinguishing system roles (isSystem: true) from custom ones before allowing edit or delete.

Part of the client Platform Custom Roles module. Requires a client Access Token with tenant admin privileges.

Response Data

Each item in data.list typically includes:

FieldDescription
_idRole document id — use with Get / Update / Delete by id.
nameDisplay name in the Platform UI.
slugStable slug assigned to users (role field on user update).
permissionsPermission keys. "*" often means full access on system Admin.
isSystem / isDefaultFlags for built-in roles. System roles should not be deleted from the Platform UI.
metadataOptional UI or product attributes (for example color).
GET{baseUrl}/api/{apiVersion}/user-role/list?search=&page=1&limit=10

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).
is-tenanttrueTargets the tenant DB ("true", needs x-client-id).
x-client-id{{clientId}}Tenant (client) id. Required when is-tenant=true.

Query Parameters

ParameterRequiredExampleDescription
searchOptional—Case-insensitive text search (regex-escaped). Matches searchable fields such as name and slug.
pageOptional1Page number, 1-based. Default 1.
limitOptional10Page size — items per page. Default 10.

Success Response (HTTP 200 OK)

On success, the API returns list and pagination. The example includes system Admin / User plus one custom role.

json
{
  "success": true,
  "message": "Role list fetched successfully",
  "data": {
    "list": [
      {
        "_id": "66bp...0001",
        "name": "Admin",
        "slug": "admin",
        "description": "Full tenant administrator",
        "permissions": [
          "*"
        ],
        "isDefault": true,
        "isSystem": true,
        "metadata": {},
        "createdAt": "2026-06-22T05:40:02.000Z",
        "updatedAt": "2026-06-22T05:40:02.000Z"
      },
      {
        "_id": "66b0...0002",
        "name": "User",
        "slug": "user",
        "description": "Standard chat user",
        "permissions": [],
        "isDefault": true,
        "isSystem": true,
        "metadata": {},
        "createdAt": "2026-06-22T05:40:02.000Z",
        "updatedAt": "2026-06-22T05:40:02.000Z"
      },
      {
        "_id": "66b0...c9d0",
        "name": "Sales Manager",
        "slug": "sales-manager",
        "description": "Manages the sales desk",
        "permissions": [
          "chat.read",
          "chat.assign"
        ],
        "isDefault": false,
        "isSystem": false,
        "metadata": {
          "color": "#3b82f6"
        },
        "createdAt": "2026-06-23T10:00:00.000Z",
        "updatedAt": "2026-06-23T10:00:00.000Z"
      }
    ],
    "pagination": {
      "currentPage": 1,
      "totalCount": 3,
      "hasNextPage": false,
      "hasPreviousPage": false,
      "pageSize": 10
    }
  },
  "error": null
}

Common Errors

List fails when the token is missing or lacks tenant admin access.

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
}
CodeReason
401 UnauthorizedAccess Token is missing, invalid, or expired.
403 ForbiddenTenant admin privileges required for Platform Custom Roles.
500 Internal Server ErrorAn unexpected error occurred while listing roles.

Best Practices

  • Hide or disable Delete for rows where isSystem is true.
  • Cache the list briefly for role pickers; refresh after Create / Update / Delete.
  • Use slug (not _id) when assigning a role on a user.
  • Always send tenant headers with a client Bearer token over HTTPS.

Roles list ready

Bind the list to your Custom Roles table, then open a row with Get by ID or start Create for a new custom role.

PreviousCreateNextGet by ID

On this page

OverviewWhen to use this endpoint?Response DataRequest HeadersQuery ParametersSuccess ResponseCommon ErrorsBest Practices