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.

GET POST PUT PATCH DELETE 6 Endpoints Auth Required
Base URL https://bogusapi.com/api/roles
GET /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.

Headers
Authorization : Bearer a6d07d82-80fc-4c1e-99fc-cff423dfbfd6....
Response: 200 OK
GET /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.

Path Parameters
ParameterTypeRequiredDescription
id integer Required Unique role identifier
Headers
Authorization : Bearer cc08f839-dd74-4d1f-842c-93805f95fc56....
Response: 200 OK
GET /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.

Headers
Authorization : Bearer 816aa8d7-1c03-4ba3-bf62-8cb4802bcce1....
Response: 404 Not Found
{}
POST /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.

Request Body
FieldTypeRequiredDescription
name string Required Unique role name
description string Required Human-readable description of the role
Authorization : Bearer c3a8c13f-7188-4326-87ec-62e3689cb227....
Response: 201 Created
PUT /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.

Request Body
FieldTypeRequiredDescription
name string Required Updated role name
description string Required Updated role description
Authorization : Bearer 7a7f6086-50b7-4ed9-a06d-a442cee2abe1....
Response: 200 OK
PATCH /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.

Request Body

Array of JSON Patch operations. Supported operation: replace.

FieldTypeRequiredDescription
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....
Response: 200 OK
DELETE /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.

Path Parameters
ParameterTypeRequiredDescription
id integer Required ID of the role to delete
Headers
Authorization : Bearer 720e5412-7545-4d8b-8cb4-1e18ade58c82....
Response: 204 No Content
{}