openapi: 3.0.1
info:
  title: Evolution Foundation - Auth Service - Health
  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/health:
    get:
      summary: API health check
      description: Health check endpoint for API
      operationId: apiHealthCheck
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: API is healthy
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      status:
                        type: string
                        description: API status
                        example: ok
                      database:
                        type: string
                        description: Database connection status
                        example: connected
                      redis:
                        type: string
                        description: Redis connection status
                        example: connected
                      version:
                        type: string
                        description: API version
                        example: 1.0.0
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2026-01-28T21:34:06Z'
                  message:
                    type: string
                    description: Success message
                    example: API is healthy
              example:
                success: true
                data:
                  status: ok
                  database: connected
                  redis: connected
                  version: 1.0.0
                meta:
                  timestamp: '2026-01-28T21:34:06Z'
                message: API is healthy
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid request parameters
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request parameters
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/health
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized access
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/health
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Access forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: You do not have permission to access this resource
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/health
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Health endpoint not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/health
                      method: GET
        '500':
          description: Internal Server Error (server error)
          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/health
                      method: GET
  /health:
    get:
      summary: Health check (liveness)
      description: Liveness probe - always returns 200 if app is running
      operationId: healthCheck
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Service is running
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Overall service health status
                    example: healthy
                  timestamp:
                    type: string
                    format: date-time
                    description: Response timestamp
                    example: 2026-01-28T22:05:39.211939+00:00Z
                  duration:
                    type: string
                    description: Total health check duration
                    example: 0.069s
                  components:
                    type: array
                    description: Array of component health checks
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          description: Component name
                          example: database
                        status:
                          type: string
                          description: Component health status
                          example: healthy
                        message:
                          type: string
                          description: Component status message
                          example: Database is healthy
                        details:
                          type: object
                          nullable: true
                          description: Additional component details
                        timestamp:
                          type: string
                          format: date-time
                          description: Component check timestamp
                          example: 2026-01-28T22:05:39.186045+00:00Z
                        duration:
                          type: string
                          description: Component check duration
                          example: 0.043s
              example:
                status: healthy
                timestamp: 2026-01-28T22:05:39.211939+00:00Z
                duration: 0.069s
                components:
                - name: database
                  status: healthy
                  message: Database is healthy
                  details: null
                  timestamp: 2026-01-28T22:05:39.186045+00:00Z
                  duration: 0.043s
                - name: database_connections
                  status: healthy
                  message: Database connections are healthy
                  details:
                    pool_size: 5
                    checked_in: 1
                    checked_out: 0
                    overflow: -4
                    total_connections: 1
                  timestamp: 2026-01-28T22:05:39.207571+00:00Z
                  duration: 0.000s
                - name: redis
                  status: healthy
                  message: Redis is healthy
                  details:
                    connected_clients: 329
                    used_memory_human: 6.07M
                    redis_version: 7.4.7
                  timestamp: 2026-01-28T22:05:39.211371+00:00Z
                  duration: 0.004s
                - name: memory
                  status: healthy
                  message: Memory usage is normal
                  details:
                    system_memory_used_mb: 6946.76
                    system_memory_total_mb: 15613.73
                    system_memory_percent: 46.7
                    process_memory_rss_mb: 304.94
                    process_memory_vms_mb: 555.97
                  timestamp: 2026-01-28T22:05:39.211906+00:00Z
                  duration: 0.000s
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid request parameters
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request parameters
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /health
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized access
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /health
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Access forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: You do not have permission to access this resource
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /health
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Health endpoint not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /health
                      method: GET
        '500':
          description: Internal Server Error (server error)
          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: /health
                      method: GET
  /ready:
    get:
      summary: Readiness check
      description: Readiness probe - returns 200 only if dependencies are ready
      operationId: readinessCheck
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Service is ready
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Overall service readiness status
                    example: healthy
                  timestamp:
                    type: string
                    format: date-time
                    description: Response timestamp
                    example: 2026-01-28T22:09:02.538776+00:00Z
                  duration:
                    type: string
                    description: Total readiness check duration
                    example: 0.069s
                  components:
                    type: array
                    description: Array of component readiness checks
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          description: Component name
                          example: database_ping
                        status:
                          type: string
                          description: Component readiness status
                          example: healthy
                        message:
                          type: string
                          description: Component status message
                          example: Database ping successful
                        details:
                          type: object
                          nullable: true
                          description: Additional component details
                        timestamp:
                          type: string
                          format: date-time
                          description: Component check timestamp
                          example: 2026-01-28T22:09:02.513767+00:00Z
                        duration:
                          type: string
                          description: Component check duration
                          example: 0.044s
              example:
                status: healthy
                timestamp: 2026-01-28T22:09:02.538776+00:00Z
                duration: 0.069s
                components:
                - name: database_ping
                  status: healthy
                  message: Database ping successful
                  details: null
                  timestamp: 2026-01-28T22:09:02.513767+00:00Z
                  duration: 0.044s
                - name: redis
                  status: healthy
                  message: Redis is healthy
                  details:
                    connected_clients: 324
                    used_memory_human: 6.06M
                    redis_version: 7.4.7
                  timestamp: 2026-01-28T22:09:02.538566+00:00Z
                  duration: 0.003s
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid request parameters
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request parameters
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /ready
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized access
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /ready
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Access forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: You do not have permission to access this resource
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /ready
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Readiness endpoint not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /ready
                      method: GET
        '500':
          description: Internal Server Error (server error)
          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: /ready
                      method: GET
        '503':
          description: Service Unavailable (service not available)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                service_unavailable:
                  summary: Service is not ready
                  value:
                    success: false
                    error:
                      code: SERVICE_UNAVAILABLE
                      message: Service is not ready
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /ready
                      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
