RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
CreateListGet by IDUpdateDelete
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

Delete Custom Role

Overview

Permanently delete a custom role from your tenant in the client Platform Custom Roles module.

Delete is blocked while users are still assigned this role (HTTP 409). Reassign those users first (Platform → Users → Update), then delete. Do not delete built-in system roles (isSystem: true).

When to use this endpoint?

Use Delete Custom Role when:

  • An admin removes an unused custom role from Platform → Custom Roles.
  • You are cleaning up obsolete desk or department roles after reassigning users.
  • The role is custom (isSystem: false) and no longer needed.

Part of the client Platform Custom Roles module. If users still use this role slug, the API returns 409 Conflict until you reassign them.

DELETE{baseUrl}/api/{apiVersion}/user-role/:roleId

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.

Path Parameters

ParameterExampleDescription
roleId66b0f1a2c3d4e5f6a7b8c9d0The role's _id to delete. Get it from List Custom Roles.

Success Response (HTTP 200 OK)

On success, the role is removed. data may be null.

json
{
  "success": true,
  "message": "Role deleted successfully",
  "data": null,
  "error": null
}

Common Errors

Delete fails when the role is still assigned to users, the id is missing, or the token lacks admin access.

HTTP 409 Conflict — Role in use

json
{
  "success": false,
  "message": "Cannot delete: 3 user(s) still assigned this role",
  "data": null,
  "error": null
}

HTTP 404 Not Found — Role missing

json
{
  "success": false,
  "message": "Entity not found",
  "data": null,
  "error": "Entity not found"
}

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
409 ConflictOne or more users still have this role assigned. Reassign them first, then retry Delete.
404 Not FoundNo role exists for the given roleId.
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 deleting the role.

Best Practices

  • Before delete, list users with this role slug and reassign them via Platform → Users → Update.
  • Hide Delete for isSystem roles in the Platform UI.
  • Show the 409 message clearly so admins know how many users still use the role.
  • Always send tenant headers with a client Bearer token over HTTPS.

Role deleted

Remove the row from your Custom Roles table and refresh role pickers so obsolete slugs are no longer selectable.

PreviousUpdateNextList

On this page

OverviewWhen to use this endpoint?Request HeadersPath ParametersSuccess ResponseCommon ErrorsBest Practices