Skip to main content

GET /api/roles

Retrieves a complete list of all roles in the authorization system, including their assigned permissions.

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Response

Returns an array of role objects.
id
UUID
Unique identifier of the role
name
string
The name of the role
description
string
The description of the role
permissions
array
List of permissions assigned to this role
id
UUID
Permission unique identifier
name
string
Permission name
description
string
Permission description
status
string
Permission status (ACTIVE, INACTIVE)
status
string
Current status of the role (ACTIVE, INACTIVE)

Error Responses

  • 500 Internal Server Error: Unexpected server error

Example Request

curl -X GET https://api.example.com/api/roles \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Administrator",
    "description": "Full system access with all permissions",
    "permissions": [
      {
        "id": "660e8400-e29b-41d4-a716-446655440001",
        "name": "users:write",
        "description": "Permission to create and modify users",
        "status": "ACTIVE"
      },
      {
        "id": "660e8400-e29b-41d4-a716-446655440002",
        "name": "users:read",
        "description": "Permission to view user information",
        "status": "ACTIVE"
      }
    ],
    "status": "ACTIVE"
  },
  {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "name": "Editor",
    "description": "Can edit content but not manage users",
    "permissions": [
      {
        "id": "660e8400-e29b-41d4-a716-446655440003",
        "name": "content:write",
        "description": "Permission to create and modify content",
        "status": "ACTIVE"
      }
    ],
    "status": "ACTIVE"
  }
]

Example Error Response

{
  "timestamp": "2024-01-15T10:30:00Z",
  "requestId": "abc-123-def",
  "message": "Internal server error",
  "detail": "An unexpected error occurred while retrieving roles"
}

Build docs developers (and LLMs) love