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.
{baseUrl}/api/{apiVersion}/user-role/:roleIdAuthentication
Required (Bearer token)
Tenant-scoped
Yes (tenant DB — requires x-client-id)
Request Headers
| Header | Value | Description |
|---|---|---|
| Authorization | Bearer <access_token> | Client Access Token with tenant admin privileges (Platform panel). |
| is-tenant | true | Targets the tenant DB ("true", needs x-client-id). |
| x-client-id | {{clientId}} | Tenant (client) id. Required when is-tenant=true. |
Path Parameters
| Parameter | Example | Description |
|---|---|---|
| roleId | 66b0f1a2c3d4e5f6a7b8c9d0 | The 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.
{
"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
{
"success": false,
"message": "Cannot delete: 3 user(s) still assigned this role",
"data": null,
"error": null
}HTTP 404 Not Found — Role missing
{
"success": false,
"message": "Entity not found",
"data": null,
"error": "Entity not found"
}HTTP 401 Unauthorized — No token
{
"success": false,
"message": "No token, authorization denied",
"data": null,
"error": "Unauthorized"
}HTTP 403 Forbidden — Tenant admin required
{
"success": false,
"message": "Access denied: tenant admin privileges required",
"data": null,
"error": null
}| Code | Reason |
|---|---|
| 409 Conflict | One or more users still have this role assigned. Reassign them first, then retry Delete. |
| 404 Not Found | No role exists for the given roleId. |
| 401 Unauthorized | Access Token is missing, invalid, or expired. |
| 403 Forbidden | Tenant admin privileges required for Platform Custom Roles. |
| 500 Internal Server Error | An 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
isSystemroles 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.