> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corebanq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Login

> Authenticate user and get tokens. If MFA is enabled for the user, returns MFA challenge instead of tokens.



## OpenAPI

````yaml post /v1/authenticate
openapi: 3.0.0
info:
  title: Authentication API
  version: 1.0.0
  description: API for authentication and authorization
servers: []
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Authentication
    description: Authentication operations
paths:
  /v1/authenticate:
    post:
      tags:
        - Authentication
      summary: Login
      description: >-
        Authenticate user and get tokens. If MFA is enabled for the user,
        returns MFA challenge instead of tokens.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthCredentials'
            examples:
              basic:
                summary: Basic login
                value:
                  username: user@example.com
                  password: secure_password
      responses:
        '200':
          description: Authentication successful or MFA required
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/TokenResponse'
                  - $ref: '#/components/schemas/MFAResponse'
              examples:
                tokens:
                  summary: Direct authentication success
                  value:
                    access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    expires_in: 900
                    user_id: 123e4567-e89b-12d3-a456-426614174000
                mfa_required:
                  summary: MFA verification required
                  value:
                    credential_type: phone
                    user_id: 123e4567-e89b-12d3-a456-426614174000
                    message: An OTP has been sent to your phone successfully.
        '400':
          $ref: '#/components/responses/InvalidCredentials'
        '429':
          $ref: '#/components/responses/AccountLocked'
components:
  schemas:
    AuthCredentials:
      type: object
      required:
        - username
        - password
      properties:
        username:
          type: string
          example: user@example.com
        password:
          type: string
          format: password
          example: secure_password
    TokenResponse:
      type: object
      required:
        - access_token
        - expires_in
        - user_id
      properties:
        access_token:
          type: string
        expires_in:
          type: integer
          description: Token expiration in seconds
        user_id:
          type: string
          format: uuid
    MFAResponse:
      type: object
      required:
        - credential_type
        - user_id
        - message
      properties:
        credential_type:
          type: string
          enum:
            - email
            - phone
            - totp
          description: Type of MFA credential to be verified
        user_id:
          type: string
          format: uuid
          description: User ID needed for the subsequent `Verify 2FA` call
        message:
          type: string
          description: Human-readable message explaining what action has been completed
          example: An OTP has been sent to your phone successfully.
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
  responses:
    InvalidCredentials:
      description: Invalid credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: auth.unauthorized
            message: Invalid credentials
    AccountLocked:
      description: Account locked
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: auth.account_locked
            message: Account locked for 15 minutes
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````