Roles API
v1.0 • REST • JSON
Full CRUD management for roles. Create, retrieve, update, patch, and delete role records with support for user assignment tracking.
Quick Reference
/api/roles
200 OK
Get All Roles
Retrieves the complete list of roles available in the system. Each role includes its name, description, and the number of users currently assigned to it.
Authorization : Bearer a6d07d82-80fc-4c1e-99fc-cff423dfbfd6....
/api/roles/{id}
200 OK
Get Single Role
Fetches full details for a specific role by its numeric ID, including name, description, and user count.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Required | Unique role identifier |
Authorization : Bearer cc08f839-dd74-4d1f-842c-93805f95fc56....
/api/roles/{id}
404 Not Found
Role Not Found
Returned when the requested role ID does not exist in the system. Use this example to test error-handling logic and build graceful fallback UI for missing role resources.
Authorization : Bearer 816aa8d7-1c03-4ba3-bf62-8cb4802bcce1....
{}
/api/roles
201 Created
Create Role
Registers a new role with a name and description. On success, returns the newly created role object including the auto-generated ID.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Required | Unique role name |
description |
string | Required | Human-readable description of the role |
Authorization : Bearer c3a8c13f-7188-4326-87ec-62e3689cb227....
/api/roles/{id}
200 OK
Update Role
Fully replaces an existing role's data with the values in the request body. A successful update returns 200 OK with response body.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Required | Updated role name |
description |
string | Required | Updated role description |
Authorization : Bearer 7a7f6086-50b7-4ed9-a06d-a442cee2abe1....
/api/roles/{id}
200 OK
Patch Role
Applies a partial update to an existing role using a JSON Patch (RFC 6902) document. Only the fields specified in the patch operations are modified. Returns 200 OK with response body on success.
Array of JSON Patch operations. Supported operation: replace.
| Field | Type | Required | Description |
|---|---|---|---|
op |
string | Required | Operation type, e.g. replace |
path |
string | Required | JSON Pointer to the field, e.g. /name |
value |
any | Required | The new value for the field |
Content-Type : application/json-patch+json
Authorization : Bearer 937ff17c-a4a5-42d5-af2e-b3ba9184c1b5....
/api/roles/{id}
204 No Content
Delete Role
Permanently removes a role from the system by its ID. This action is irreversible � once deleted, the role record cannot be recovered through the API.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Required | ID of the role to delete |
Authorization : Bearer 720e5412-7545-4d8b-8cb4-1e18ade58c82....
{}