openapi: 3.0.1
info:
  title: Evolution Foundation - Auth Service - Plans
  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/plans:
    get:
      summary: List plans
      description: List all available plans
      operationId: listPlans
      security:
      - ApiAccessTokenAuth: []
      parameters:
      - name: page
        in: query
        schema:
          type: integer
      - name: per_page
        in: query
        schema:
          type: integer
      - name: search
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Plans retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        name:
                          type: string
                        description:
                          type: string
                        is_active:
                          type: boolean
                        features:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                format: uuid
                              plan_id:
                                type: string
                                format: uuid
                              feature_id:
                                type: string
                                format: uuid
                              feature_name:
                                type: string
                              feature_key:
                                type: string
                              value:
                                type: string
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                  meta:
                    type: object
                    properties:
                      pagination:
                        type: object
                        properties:
                          page:
                            type: integer
                          pageSize:
                            type: integer
                          total:
                            type: integer
                          totalPages:
                            type: integer
                          hasNextPage:
                            type: boolean
                          hasPreviousPage:
                            type: boolean
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    data:
                    - id: 880e8400-e29b-41d4-a716-446655440003
                      name: Professional
                      description: Professional plan with advanced features
                      is_active: true
                      features:
                      - id: 990e8400-e29b-41d4-a716-446655440004
                        plan_id: 880e8400-e29b-41d4-a716-446655440003
                        feature_id: da6246c8-dc3f-421a-b49c-01f85a39abff
                        feature_name: Max agents per account
                        feature_key: max_agents_per_account
                        value: '10'
                        created_at: '2025-12-11T13:10:37.760Z'
                        updated_at: '2025-12-11T13:10:37.760Z'
                      created_at: '2024-01-01T00:00:00Z'
                      updated_at: '2024-01-15T10:30:00Z'
                    meta:
                      pagination:
                        page: 1
                        pageSize: 20
                        total: 1
                        totalPages: 1
                        hasNextPage: false
                        hasPreviousPage: false
                      timestamp: '2026-02-04T14:26:31Z'
                    message: Plans 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/plans
                      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/plans
                      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: plans.read
                        record: Plan
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/plans
                      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/plans
                      method: GET
  /api/v1/plans/{id}:
    parameters:
    - name: id
      in: path
      description: Plan ID
      required: true
      schema:
        type: string
        format: uuid
    get:
      summary: Get plan details
      description: Get details of a specific plan
      operationId: getPlan
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Plan retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      name:
                        type: string
                      description:
                        type: string
                      is_active:
                        type: boolean
                      features:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                            plan_id:
                              type: string
                              format: uuid
                            feature_id:
                              type: string
                              format: uuid
                            feature_name:
                              type: string
                            feature_key:
                              type: string
                            value:
                              type: string
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    data:
                      id: 880e8400-e29b-41d4-a716-446655440003
                      name: Professional
                      description: Professional plan with advanced features
                      is_active: true
                      features:
                      - id: 990e8400-e29b-41d4-a716-446655440004
                        plan_id: 880e8400-e29b-41d4-a716-446655440003
                        feature_id: da6246c8-dc3f-421a-b49c-01f85a39abff
                        feature_name: Max agents per account
                        feature_key: max_agents_per_account
                        value: '10'
                        created_at: '2025-12-11T13:10:37.760Z'
                        updated_at: '2025-12-11T13:10:37.760Z'
                      created_at: '2024-01-01T00:00:00Z'
                      updated_at: '2024-01-15T10:30:00Z'
                    meta:
                      timestamp: '2026-02-04T14:26:31Z'
                    message: Plan retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid plan ID format
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid plan ID format
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/plans/{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/plans/{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: plans.read
                        record: Plan
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/plans/{id}
                      method: GET
        '404':
          description: Not Found (plan not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                plan_not_found:
                  summary: Plan not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Plan not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/plans/{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/plans/{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
    Plan:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
          nullable: true
        is_active:
          type: boolean
        features:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              feature_id:
                type: string
                format: uuid
              feature:
                $ref: '#/components/schemas/Feature'
              value:
                type: string
              created_at:
                type: string
                format: date-time
        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
