openapi: 3.0.1
info:
  title: Evolution Foundation - Auth Service - Authentication
  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/auth/forgot_password:
    post:
      summary: Request password reset
      description: Request password reset instructions via email
      operationId: forgotPassword
      parameters: []
      responses:
        '200':
          description: Password reset email sent
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    data:
                      success: true
                    meta:
                      timestamp: '2026-02-04T16:26:17Z'
                    message: Password reset instructions have been sent to your email
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request format
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request format
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/forgot_password
                      method: POST
        '422':
          description: Unprocessable Entity (validation errors)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                email_required:
                  summary: Email is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Email is required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/forgot_password
                      method: POST
                operation_failed:
                  summary: Failed to process password reset request
                  value:
                    success: false
                    error:
                      code: OPERATION_FAILED
                      message: Failed to process password reset request
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/forgot_password
                      method: POST
        '503':
          description: Service Unavailable (erro no envio de email)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                email_delivery_failed:
                  summary: Unable to send password reset email
                  value:
                    success: false
                    error:
                      code: EMAIL_DELIVERY_FAILED
                      message: Unable to send password reset email. Please contact support or try again later.
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/forgot_password
                      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/auth/forgot_password
                      method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                redirect_url:
                  type: string
                config_name:
                  type: string
              required:
              - email
  /api/v1/auth/login:
    post:
      summary: User login
      description: Authenticate user with email and password
      operationId: loginUser
      parameters: []
      responses:
        '200':
          description: Login successful
          headers:
            access-token:
              schema:
                type: string
              description: Authentication token
            client:
              schema:
                type: string
              description: Client identifier
            uid:
              schema:
                type: string
              description: User identifier
            expiry:
              schema:
                type: string
              description: Token expiration timestamp
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginResponse'
        '202':
          description: MFA required
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      mfa_required:
                        type: boolean
                      mfa_method:
                        type: string
                        enum:
                        - totp
                        - email
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Email or password is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Email and password are required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/login
                      method: POST
        '401':
          description: Unauthorized (invalid credentials)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_credentials:
                  summary: Invalid email or password
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Invalid email or password
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/login
                      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/auth/login
                      method: POST
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  description: User email address
                password:
                  type: string
                  description: User password
              required:
              - email
              - password
  /api/v1/auth/logout:
    post:
      summary: User logout
      description: Logout user and invalidate tokens
      operationId: logoutUser
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Logout successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '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/auth/logout
                      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/auth/logout
                      method: POST
  /api/v1/auth/me:
    get:
      summary: Get current user
      description: Get current authenticated user information
      operationId: getCurrentUser
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: User information retrieved
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      user:
                        $ref: '#/components/schemas/User'
                      accounts:
                        type: array
                        items:
                          $ref: '#/components/schemas/Account'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '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/auth/me
                      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/auth/me
                      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/auth/me
                      method: GET
  /api/v1/auth/refresh:
    post:
      summary: Refresh token
      description: Refresh authentication token
      operationId: refreshToken
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Token refreshed successfully
          headers:
            access-token:
              schema:
                type: string
              description: New authentication token
            client:
              schema:
                type: string
              description: Client identifier
            uid:
              schema:
                type: string
              description: User identifier
            expiry:
              schema:
                type: string
              description: Token expiration timestamp
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      access_token:
                        type: string
                      expires_in:
                        type: integer
                      token_type:
                        type: string
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '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/auth/refresh
                      method: POST
        '401':
          description: Unauthorized (invalid or missing refresh token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Refresh token not found or invalid
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Token refresh failed
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/refresh
                      method: POST
                refresh_token_not_found:
                  summary: Refresh token not found
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Refresh token not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/refresh
                      method: POST
                invalid_refresh_token:
                  summary: Invalid refresh token
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Invalid refresh token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/refresh
                      method: POST
                refresh_token_expired:
                  summary: Refresh token expired
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Refresh token expired
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/refresh
                      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/auth/refresh
                      method: POST
  /api/v1/auth/register:
    post:
      summary: Register new user
      description: Register a new user account
      operationId: registerUser
      security:
      - ApiAccessTokenAuth: []
      parameters: []
      responses:
        '201':
          description: User registered successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      user:
                        $ref: '#/components/schemas/User'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '400':
          description: Bad Request (invalid data or missing parameters)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_required_field:
                  summary: Missing required field
                  value:
                    success: false
                    error:
                      code: MISSING_REQUIRED_FIELD
                      message: Required parameter is missing
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/register
                      method: POST
                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/auth/register
                      method: POST
        '422':
          description: Unprocessable Entity (model validation errors)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Validation errors
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Validation failed
                      details:
                        email:
                        - has already been taken
                        password:
                        - is too short (minimum is 8 characters)
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/register
                      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/auth/register
                      method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
                  minLength: 8
                password_confirmation:
                  type: string
                name:
                  type: string
                account_name:
                  type: string
                user_full_name:
                  type: string
                locale:
                  type: string
                  default: en
              required:
              - email
              - password
              - password_confirmation
  /api/v1/auth/reset_password:
    post:
      summary: Reset password
      description: Reset password using reset token
      operationId: resetPassword
      parameters: []
      responses:
        '200':
          description: Password reset successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    data:
                      success: true
                    meta:
                      timestamp: '2026-02-04T16:26:17Z'
                    message: Your password has been reset successfully. Please log in with your new password.
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request format
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request format
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
        '422':
          description: Unprocessable Entity (validation errors)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                token_required:
                  summary: Reset password token is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Reset password token is required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                password_required:
                  summary: Password is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Password is required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                password_confirmation_required:
                  summary: Password confirmation is required
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Password confirmation is required
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                password_mismatch:
                  summary: Password confirmation does not match
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Password confirmation does not match
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                invalid_token:
                  summary: Invalid or expired reset password token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid or expired reset password token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                expired_token:
                  summary: Reset password token has expired
                  value:
                    success: false
                    error:
                      code: EXPIRED_TOKEN
                      message: Reset password token has expired. Please request a new one
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      method: POST
                validation_errors:
                  summary: Password validation failed
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Password is too short
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/reset_password
                      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/auth/reset_password
                      method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                reset_password_token:
                  type: string
                password:
                  type: string
                  minLength: 8
                password_confirmation:
                  type: string
              required:
              - reset_password_token
              - password
              - password_confirmation
  /api/v1/auth/validate:
    post:
      summary: Validate token
      description: Validate authentication token and return user data
      operationId: validateAuthToken
      security:
      - ApiAccessTokenAuth: []
      parameters: []
      responses:
        '200':
          description: Token validated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      valid:
                        type: boolean
                      user:
                        $ref: '#/components/schemas/User'
                      token:
                        type: object
                        properties:
                          type:
                            type: string
                          access_token:
                            type: string
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '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/auth/validate
                      method: POST
        '401':
          description: Unauthorized (invalid, expired or not found token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/validate
                      method: POST
                expired_token:
                  summary: Expired token
                  value:
                    success: false
                    error:
                      code: EXPIRED_TOKEN
                      message: Token has expired
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/validate
                      method: POST
                token_not_found:
                  summary: Token not found
                  value:
                    success: false
                    error:
                      code: TOKEN_NOT_FOUND
                      message: Token not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/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/auth/validate
                      method: POST
  /api/v1/auth/validate_token:
    get:
      summary: Validate token
      description: Validate current authentication token and return user data
      operationId: validateToken
      security:
      - ApiAccessTokenAuth: []
      responses:
        '200':
          description: Token is valid and user data returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      user:
                        $ref: '#/components/schemas/User'
                      accounts:
                        type: array
                        items:
                          $ref: '#/components/schemas/Account'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                  message:
                    type: string
        '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/auth/validate_token
                      method: GET
        '401':
          description: Unauthorized (invalid, expired or not found token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid token
                  value:
                    success: false
                    error:
                      code: INVALID_TOKEN
                      message: Invalid token
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/validate_token
                      method: GET
                expired_token:
                  summary: Expired token
                  value:
                    success: false
                    error:
                      code: EXPIRED_TOKEN
                      message: Token has expired
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/validate_token
                      method: GET
                token_not_found:
                  summary: Token not found
                  value:
                    success: false
                    error:
                      code: TOKEN_NOT_FOUND
                      message: Token not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/auth/validate_token
                      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/auth/validate_token
                      method: GET
components:
  schemas:
    Account:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Account unique identifier
        name:
          type: string
          description: Account name
        domain:
          type: string
          nullable: true
          description: Account custom domain
        support_email:
          type: string
          format: email
          nullable: true
          description: Support email address
        locale:
          type: string
          enum:
          - en
          - pt
          - pt_BR
          - es
          - fr
          - de
          description: Account locale
        status:
          type: string
          enum:
          - active
          - suspended
          description: Account status
        settings:
          type: object
          additionalProperties: true
          description: Account settings
        custom_attributes:
          type: object
          additionalProperties: true
          description: Custom account attributes
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        role:
          type: string
          description: User role in this account
    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
    LoginResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            user:
              $ref: '#/components/schemas/User'
            accounts:
              type: array
              items:
                $ref: '#/components/schemas/Account'
            access_token:
              type: string
            expires_in:
              type: integer
            token_type:
              type: string
        message:
          type: string
    User:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        email:
          type: string
          format: email
        type:
          type: string
          enum:
          - User
          - SuperAdmin
        role:
          type: object
          nullable: true
          properties:
            id:
              type: string
              format: uuid
            key:
              type: string
            name:
              type: string
        pubsub_token:
          type: string
        display_name:
          type: string
          nullable: true
        availability:
          type: string
          enum:
          - online
          - busy
          - offline
        mfa_enabled:
          type: boolean
        confirmed:
          type: boolean
        custom_attributes:
          type: object
          additionalProperties: true
        ui_settings:
          type: object
          additionalProperties: true
        is_super_admin:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Error message
        message:
          type: string
          description: Error message
        details:
          type: object
          description: Additional error details
      required:
      - error
    OAuthApplication:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        uid:
          type: string
        secret:
          type: string
        redirect_uri:
          type: string
        scopes:
          type: string
        confidential:
          type: boolean
        trusted:
          type: boolean
        account_id:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ValidationErrorResponse:
      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: array
              items:
                type: object
                required:
                - field
                - messages
                - full_messages
                properties:
                  field:
                    type: string
                    example: email
                  messages:
                    type: array
                    items:
                      type: string
                    example:
                    - is invalid
                    - has already been taken
                  full_messages:
                    type: array
                    items:
                      type: string
                    example:
                    - Email is invalid
                    - Email has already been taken
        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
            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
