> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dados.rio/llms.txt
> Use this file to discover all available pages before exploring further.

# List all roles

> List all roles available in the system.

**Authorization**: All authenticated users can list roles.

**Pagination**: Use `skip` and `limit` parameters to control pagination.
Maximum limit is 100 roles per request.

**Use Cases**:
- Display available roles in user interfaces
- Role selection during group or user management
- Administrative overview of system roles
- Integration with external systems requiring role information

**System Roles**: The system includes built-in roles like `superadmin` which cannot be deleted.



## OpenAPI

````yaml https://raw.githubusercontent.com/prefeitura-rio/heimdall/main/docs/api/openapi.json get /api/v1/roles/
openapi: 3.1.0
info:
  title: Heimdall Admin Service
  description: >-
    # Heimdall Admin Service API


    A comprehensive admin service for user and group management with
    authorization powered by Cerbos.


    ## Features


    - **User Management**: Automatic user creation from JWT tokens with
    role-based access control

    - **Group Management**: Create, manage, and assign users to groups with
    hierarchical permissions

    - **Role Management**: Define and assign roles to users and groups

    - **Mapping Management**: Configure API endpoint to action mappings for
    authorization

    - **Action Management**: Define available actions for fine-grained
    permission control

    - **Cerbos Integration**: Policy-based authorization with external Cerbos
    service

    - **Audit Logging**: Comprehensive audit trail for all administrative
    operations

    - **Redis Caching**: High-performance caching for frequently accessed data
  version: 1.0.0
servers:
  - url: https://services.pref.rio/heimdall-admin
    description: Production server
  - url: https://services.staging.app.dados.rio/heimdall-admin
    description: Staging server
security: []
tags:
  - name: health
    description: Service health and readiness checks
  - name: users
    description: >-
      User management operations. Users are automatically created from JWT
      tokens.
  - name: groups
    description: >-
      Group management operations. Groups organize users and can have roles
      assigned.
  - name: memberships
    description: Group membership management. Assign and remove users from groups.
  - name: roles
    description: >-
      Role management operations. Roles define permissions that can be assigned
      to users or groups.
  - name: actions
    description: >-
      Action management operations. Actions define the granular permissions
      available in the system.
  - name: mappings
    description: >-
      API endpoint to action mapping configuration. Maps HTTP endpoints to
      authorization actions.
paths:
  /api/v1/roles/:
    get:
      tags:
        - roles
      summary: List all roles
      description: >-
        List all roles available in the system.


        **Authorization**: All authenticated users can list roles.


        **Pagination**: Use `skip` and `limit` parameters to control pagination.

        Maximum limit is 100 roles per request.


        **Use Cases**:

        - Display available roles in user interfaces

        - Role selection during group or user management

        - Administrative overview of system roles

        - Integration with external systems requiring role information


        **System Roles**: The system includes built-in roles like `superadmin`
        which cannot be deleted.
      operationId: list_roles_api_v1_roles__get
      parameters:
        - name: skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            description: Number of items to skip
            default: 0
            title: Skip
          description: Number of items to skip
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 1
            description: Maximum number of items to return
            default: 50
            title: Limit
          description: Maximum number of items to return
      responses:
        '200':
          description: List of roles retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponse_RoleResponse_'
              example:
                items:
                  - id: 1
                    name: superadmin
                    description: Super administrator with full system access
                  - id: 2
                    name: data_analyst:read
                    description: Data analysts with read access to analytics dashboards
                    created_by: '12345678901'
                    created_at: '2024-01-15T10:30:00Z'
                total: 25
                skip: 0
                limit: 50
                has_more: false
        '401':
          description: Unauthorized - Invalid or missing JWT token
          content:
            application/json:
              example:
                detail: Could not validate credentials
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                detail: An unexpected error occurred while retrieving roles
      security:
        - HTTPBearer: []
components:
  schemas:
    PaginatedResponse_RoleResponse_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/RoleResponse'
          type: array
          title: Items
          description: List of items for the current page
        total:
          type: integer
          minimum: 0
          title: Total
          description: Total number of items available
          example: 150
        skip:
          type: integer
          minimum: 0
          title: Skip
          description: Number of items skipped (offset)
          example: 0
        limit:
          type: integer
          maximum: 100
          minimum: 1
          title: Limit
          description: Maximum number of items returned
          example: 50
        has_more:
          type: boolean
          title: Has More
          description: Whether there are more items available
          example: true
      type: object
      required:
        - items
        - total
        - skip
        - limit
        - has_more
      title: PaginatedResponse[RoleResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RoleResponse:
      properties:
        id:
          type: integer
          title: Id
          description: Unique identifier for the role
          example: 1
        name:
          type: string
          title: Name
          description: Role name
          example: data_analyst:read
        description:
          type: string
          title: Description
          description: Role description
          example: Data analysts with read access to analytics dashboards
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
          description: CPF of the user who created this role (null for system roles)
          example: '12345678901'
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
          description: ISO timestamp when the role was created (null for system roles)
          example: '2024-01-15T10:30:00Z'
      type: object
      required:
        - id
        - name
        - description
      title: RoleResponse
      description: Response model for role information.
      example:
        created_at: '2024-01-15T10:30:00Z'
        created_by: '12345678901'
        description: Data analysts with read access to analytics dashboards
        id: 1
        name: data_analyst:read
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````