> ## 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.

# Resolve endpoint to action

> Resolve an API endpoint (path + method) to its corresponding action for authorization.

**Authorization Middleware**: This endpoint is primarily used by authorization middleware
to determine which action should be checked for a given API request.

**Path Matching**: Supports exact matches and pattern matching with path parameters
(e.g., `/api/v1/users/{user_id}` matches `/api/v1/users/123`).

**Method Matching**: HTTP method must match exactly (case-sensitive).

**Use Cases**:
- Authorization middleware determining required permissions
- API gateway integration for access control
- Dynamic permission checking in applications
- Audit logging of permission requirements



## OpenAPI

````yaml https://raw.githubusercontent.com/prefeitura-rio/heimdall/main/docs/api/openapi.json get /api/v1/mappings/
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/mappings/:
    get:
      tags:
        - mappings
      summary: Resolve endpoint to action
      description: >-
        Resolve an API endpoint (path + method) to its corresponding action for
        authorization.


        **Authorization Middleware**: This endpoint is primarily used by
        authorization middleware

        to determine which action should be checked for a given API request.


        **Path Matching**: Supports exact matches and pattern matching with path
        parameters

        (e.g., `/api/v1/users/{user_id}` matches `/api/v1/users/123`).


        **Method Matching**: HTTP method must match exactly (case-sensitive).


        **Use Cases**:

        - Authorization middleware determining required permissions

        - API gateway integration for access control

        - Dynamic permission checking in applications

        - Audit logging of permission requirements
      operationId: resolve_mapping_api_v1_mappings__get
      parameters:
        - name: path
          in: query
          required: true
          schema:
            type: string
            description: The API path to resolve (e.g., '/api/v1/users/123')
            title: Path
          description: The API path to resolve (e.g., '/api/v1/users/123')
          example: /api/v1/users/123
        - name: method
          in: query
          required: true
          schema:
            type: string
            description: The HTTP method
            title: Method
          description: The HTTP method
          example: GET
      responses:
        '200':
          description: Mapping found and resolved successfully
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/MappingResponse'
                  - type: 'null'
                title: Response Resolve Mapping Api V1 Mappings  Get
              example:
                mapping_id: 1
                action: user:read
                path_pattern: /api/v1/users/{user_id}
                method: GET
                description: Get user profile information
        '404':
          description: No mapping found for the specified path and method
          content:
            application/json:
              example:
                detail: No mapping found for path '/api/v1/unknown' and method 'GET'
        '422':
          description: Validation error - Missing or invalid query parameters
          content:
            application/json:
              example:
                detail: Validation error
                errors:
                  - loc:
                      - query
                      - path
                    msg: field required
                    type: value_error.missing
      security:
        - HTTPBearer: []
components:
  schemas:
    MappingResponse:
      properties:
        mapping_id:
          type: integer
          title: Mapping Id
          description: Unique identifier of the mapping
          example: 1
        action:
          type: string
          title: Action
          description: Action name mapped to this endpoint
          example: user:read
        path_pattern:
          type: string
          title: Path Pattern
          description: URL path pattern that matched
          example: /api/v1/users/{user_id}
        method:
          type: string
          title: Method
          description: HTTP method
          example: GET
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Mapping description
          example: Get user profile information
      type: object
      required:
        - mapping_id
        - action
        - path_pattern
        - method
      title: MappingResponse
      description: >-
        Response model for mapping resolution (used by authorization
        middleware).
      example:
        action: user:read
        description: Get user profile information
        mapping_id: 1
        method: GET
        path_pattern: /api/v1/users/{user_id}
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````