openapi: 3.0.1
info:
  title: Evolution Foundation - Auth Service - Features
  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/features:
    get:
      summary: List features
      description: List all available features
      operationId: listFeatures
      security:
      - ApiAccessTokenAuth: []
      parameters:
      - name: search
        in: query
        description: Search by feature name
        schema:
          type: string
      - name: type
        in: query
        description: Filter by feature type
        schema:
          type: string
      responses:
        '200':
          description: Features retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Feature'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                success_empty:
                  summary: Successful response with empty array
                  value:
                    success: true
                    data: []
                    meta:
                      timestamp: '2026-02-04T14:26:31Z'
                    message: Features retrieved successfully
                success_with_data:
                  summary: Successful response with features
                  value:
                    success: true
                    data:
                    - id: da6246c8-dc3f-421a-b49c-01f85a39abff
                      name: Max agents per account
                      key: max_agents_per_account
                      description: Max agents per account
                      feature_type_id: 31647713-7e62-4355-8f25-9bf525e6ef13
                      feature_type: Plan
                      enabled: true
                      created_at: '2025-12-11T13:10:37.760Z'
                      updated_at: '2025-12-11T13:10:37.760Z'
                    - id: 046b302f-bcc4-40b6-ac81-596670c10f57
                      name: Max sessions per month
                      key: max_sessions_per_month
                      description: Max sessions per month
                      feature_type_id: 31647713-7e62-4355-8f25-9bf525e6ef13
                      feature_type: Plan
                      enabled: true
                      created_at: '2025-12-11T13:10:37.888Z'
                      updated_at: '2025-12-11T13:10:37.888Z'
                    meta:
                      timestamp: '2026-02-04T14:26:31Z'
                    message: Features 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/features
                      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/features
                      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: features.read
                        record: Feature
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/features
                      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/features
                      method: GET
  /api/v1/features/types:
    get:
      summary: List feature types
      description: List all feature types
      operationId: listFeatureTypes
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Feature types retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/FeatureType'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              example:
                success: true
                data:
                - id: 006583a4-8c6a-486d-9b4b-93c43130a686
                  name: System
                  description: System level features
                  created_at: '2025-12-11T13:10:37.320Z'
                  updated_at: '2025-12-11T13:10:37.320Z'
                - id: 16cbe230-3560-4674-a4bb-99177015618a
                  name: Account
                  description: Account level features
                  created_at: '2025-12-11T13:10:37.444Z'
                  updated_at: '2025-12-11T13:10:37.444Z'
                - id: 31647713-7e62-4355-8f25-9bf525e6ef13
                  name: Plan
                  description: Plan level features
                  created_at: '2025-12-11T13:10:37.566Z'
                  updated_at: '2025-12-11T13:10:37.566Z'
                meta:
                  timestamp: '2026-01-28T17:29:07Z'
                message: Feature types 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/features/types
                      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/features/types
                      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: features.read
                        record: Feature
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/features/types
                      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/features/types
                      method: GET
  /api/v1/features/{id}:
    parameters:
    - name: id
      in: path
      description: Feature ID
      required: true
      schema:
        type: string
        format: uuid
    get:
      summary: Get feature details
      description: Get details of a specific feature
      operationId: getFeature
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Feature retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/Feature'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              example:
                success: true
                data:
                  id: da6246c8-dc3f-421a-b49c-01f85a39abff
                  name: Max agents per account
                  key: max_agents_per_account
                  description: Max agents per account
                  feature_type_id: 31647713-7e62-4355-8f25-9bf525e6ef13
                  feature_type: Plan
                  enabled: true
                  created_at: '2025-12-11T13:10:37.760Z'
                  updated_at: '2025-12-11T13:10:37.760Z'
                meta:
                  timestamp: '2026-01-28T17:21:25Z'
                message: Feature retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid feature ID format
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid feature ID format
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/features/{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/features/{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: features.read
                        record: Feature
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/features/{id}
                      method: GET
        '404':
          description: Not Found (feature not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                feature_not_found:
                  summary: Feature not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Feature not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/features/{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/features/{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
    Feature:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        key:
          type: string
        description:
          type: string
          nullable: true
        feature_type_id:
          type: string
          format: uuid
        feature_type:
          type: string
        enabled:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    FeatureType:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  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
