openapi: 3.0.1
info:
  title: Evolution Foundation - Auth Service - Resource Actions
  description: Authentication and user and account management
  version: v1.0.0
servers:
- url: https://api.evoai.app
  description: Production server
- url: http://localhost:3001
  description: Development server
  variables:
    port:
      default: '3001'
- url: '{customUrl}'
  description: Custom server
  variables:
    customUrl:
      default: https://your-instance.com
      description: Enter your server URL
paths:
  /api/v1/resource_actions:
    get:
      summary: List resource actions
      description: Get all available resources and actions configuration
      operationId: listResourceActions
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Resource actions retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      resources:
                        type: object
                        additionalProperties:
                          type: object
                          properties:
                            name:
                              type: string
                            description:
                              type: string
                            actions:
                              type: object
                              additionalProperties:
                                type: object
                                properties:
                                  name:
                                    type: string
                                  description:
                                    type: string
                      all_permissions:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                            display_name:
                              type: string
                            resource:
                              type: string
                            action:
                              type: string
                            resource_name:
                              type: string
                            action_name:
                              type: string
                            description:
                              type: string
                  meta:
                    type: object
                    properties:
                      total_resources:
                        type: integer
                        example: 71
                      total_permissions:
                        type: integer
                        example: 380
                      last_updated:
                        type: string
                        format: date-time
                        example: '2026-02-04T14:15:13Z'
                      timestamp:
                        type: string
                        format: date-time
                        example: '2026-02-04T14:15:13Z'
                  message:
                    type: string
                    example: Resource actions configuration retrieved successfully
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    data:
                      resources:
                        users:
                          name: Users
                          description: User management and administration
                          actions:
                            read:
                              name: View
                              description: View user information and list users
                            create:
                              name: Create
                              description: Create new users
                      all_permissions:
                      - key: users.read
                        display_name: Users - View
                        resource: users
                        action: read
                        resource_name: Users
                        action_name: View
                        description: View user information and list users
                    meta:
                      total_resources: 71
                      total_permissions: 380
                      last_updated: '2026-02-04T14:15:13Z'
                      timestamp: '2026-02-04T14:15:13Z'
                    message: Resource actions configuration retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid query parameters
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid query parameters
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid or missing token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions
                      method: GET
        '500':
          description: Internal Server Error (erro interno do servidor)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An unexpected error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions
                      method: GET
  /api/v1/resource_actions/validate:
    post:
      summary: Validate permission key
      description: Validate if a permission key is valid
      operationId: validatePermissionKey
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Validation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      permission_key:
                        type: string
                      valid:
                        type: boolean
                      display_name:
                        type: string
                        description: Only present when valid is true
                      resource:
                        type: string
                        description: Only present when valid is true
                      action:
                        type: string
                        description: Only present when valid is true
                      resource_name:
                        type: string
                        description: Only present when valid is true
                      action_name:
                        type: string
                        description: Only present when valid is true
                      description:
                        type: string
                        description: Only present when valid is true
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                valid_permission:
                  summary: Valid permission key
                  value:
                    success: true
                    data:
                      permission_key: users.read
                      valid: true
                      display_name: Users - View
                      resource: users
                      action: read
                      resource_name: Users
                      action_name: View
                      description: View user information and list users
                    meta:
                      timestamp: '2026-02-04T14:17:24Z'
                    message: Permission key validated successfully
                invalid_permission:
                  summary: Invalid permission key
                  value:
                    success: true
                    data:
                      permission_key: 37a1e39b-3579-47c2-bbb3-84829deae585
                      valid: false
                    meta:
                      timestamp: '2026-02-04T14:17:24Z'
                    message: Permission key is invalid
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_permission_key:
                  summary: Permission key is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Permission key is required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/validate
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid or missing token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/validate
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Insufficient permissions
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: You are not authorized to perform this action
                      details:
                        action: resource_actions.validate
                        record: ResourceAction
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/validate
                      method: POST
        '500':
          description: Internal Server Error (erro interno do servidor)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An unexpected error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/validate
                      method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                permission_key:
                  type: string
              required:
              - permission_key
  /api/v1/resource_actions/{id}:
    parameters:
    - name: id
      in: path
      description: Resource key
      required: true
      schema:
        type: string
    get:
      summary: Get resource configuration
      description: Get configuration for a specific resource
      operationId: getResourceAction
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Resource configuration retrieved
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      key:
                        type: string
                      name:
                        type: string
                      description:
                        type: string
                      actions:
                        type: object
                      permissions:
                        type: array
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid resource key format
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid resource key format
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/{id}
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid or missing token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/{id}
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Insufficient permissions
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: You are not authorized to perform this action
                      details:
                        action: resource_actions.read
                        record: ResourceAction
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/{id}
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                resource_not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Resource not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/{id}
                      method: GET
        '500':
          description: Internal Server Error (erro interno do servidor)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An unexpected error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/resource_actions/{id}
                      method: GET
components:
  schemas:
    ErrorResponse:
      type: object
      required:
      - success
      - error
      - meta
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          required:
          - code
          - message
          properties:
            code:
              type: string
              example: VALIDATION_ERROR
            message:
              type: string
              example: Validation failed
            details:
              type: object
              additionalProperties: true
              nullable: true
        meta:
          type: object
          required:
          - timestamp
          - path
          - method
          properties:
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
            path:
              type: string
              example: /api/v1/super_admin/accounts/123
            method:
              type: string
              example: POST
  securitySchemes:
    DeviseTokenAuth:
      type: apiKey
      in: header
      name: access-token
      description: Devise Token Auth - requires access-token, client, and uid headers
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    SuperAdminAuth:
      type: apiKey
      in: header
      name: api_access_token
      description: Super Admin authentication token
    ApiAccessTokenAuth:
      type: apiKey
      in: header
      name: api_access_token
      description: API access token authentication
