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

# Initiate MFA Setup

> Use this endpoint to initiate MFA setup for a user. Returns a secret and recovery codes to be stored by the user before verification.



## OpenAPI

````yaml /en/openapi/v3-current/AM-identity.yaml post /v1/users/{id}/mfa/setup
openapi: 3.1.0
info:
  title: Identity Plugin
  description: ''
  version: 2.4.2
servers:
  - url: https://identity.sandbox.lerian.net
security: []
tags:
  - name: Groups API
  - name: Applications API
  - name: Users API
  - name: MFA API
  - name: Providers API
  - name: Application Providers API
paths:
  /v1/users/{id}/mfa/setup:
    post:
      tags:
        - MFA API
      summary: Initiate MFA Setup
      description: >-
        Use this endpoint to initiate MFA setup for a user. Returns a secret and
        recovery codes to be stored by the user before verification.
      parameters:
        - $ref: '#/components/parameters/UserId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MFASetupInput'
            example:
              mfaType: app
      responses:
        '200':
          description: >-
            MFA setup initiated successfully. Store the secret and recovery
            codes before proceeding to verification.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MFASetupResponse'
              example:
                secret: JBSWY3DPEHPK3PXP
                url: >-
                  otpauth://totp/Lerian:johndoe?secret=JBSWY3DPEHPK3PXP&issuer=Lerian
                recoveryCodes:
                  - a1b2c3d4e5
                  - f6g7h8i9j0
                  - k1l2m3n4o5
                mfaType: app
                enabled: false
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error0001:
                  $ref: '#/components/examples/Error0001'
                Error0004:
                  $ref: '#/components/examples/Error0004'
                Error0007:
                  $ref: '#/components/examples/Error0007'
                Error0040:
                  $ref: '#/components/examples/Error0040'
                Error0044:
                  $ref: '#/components/examples/Error0044'
          headers: {}
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error1003:
                  $ref: '#/components/examples/Error1003'
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              examples:
                Error0006:
                  $ref: '#/components/examples/Error0006'
                Error0045:
                  $ref: '#/components/examples/Error0045'
          headers: {}
      security:
        - bearer: []
components:
  parameters:
    UserId:
      name: id
      in: path
      description: The unique identifier of the user you want to retrieve.
      required: true
      example: 019c96a0-0c21-71f9-a487-66a1258278a1
      schema:
        type: string
  schemas:
    MFASetupInput:
      description: Information required to initiate MFA setup for a user.
      type: object
      required:
        - mfaType
      properties:
        mfaType:
          type: string
          description: The type of MFA to configure.
          enum:
            - app
            - email
            - sms
    MFASetupResponse:
      description: >-
        The result of an MFA setup initiation, including the secret and recovery
        codes.
      type: object
      properties:
        secret:
          type: string
          description: TOTP secret to be stored securely by the user or app.
        url:
          type: string
          description: OTP Auth URL for QR code generation (TOTP only).
        recoveryCodes:
          type: array
          items:
            type: string
          description: One-time recovery codes to be stored by the user.
        mfaType:
          type: string
          description: The MFA type that was configured.
          enum:
            - app
            - email
            - sms
        enabled:
          type: boolean
          description: Indicates whether MFA is currently enabled.
    ErrorMessage:
      description: The response message error.
      type: object
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error.
        title:
          type: string
          description: A brief summary of the issue.
        message:
          type: string
          description: Detailed guidance for resolving the error.
  examples:
    Error0001:
      summary: Missing Fields in Request
      value:
        code: IDE-0001
        title: Missing Fields in Request
        message: Your request is missing one or more required fields.
    Error0004:
      summary: Unexpected Fields in the Request
      value:
        code: IDE-0004
        title: Unexpected Fields in the Request
        message: >-
          The request body contains more fields than expected. Please send only
          the allowed fields.
    Error0007:
      summary: Bad Request
      value:
        code: IDE-0007
        title: Bad Request
        message: The server could not understand the request due to malformed syntax.
    Error0040:
      summary: MFA Already Enabled
      value:
        code: IDE-0040
        title: MFA Already Enabled
        message: MFA is already enabled for this user.
    Error0044:
      summary: MFA Invalid Type
      value:
        code: IDE-0044
        title: MFA Invalid Type
        message: >-
          The provided MFA type is invalid. Accepted values are app, email, and
          sms.
    Error1003:
      summary: User ID Not Found
      value:
        code: IDE-1003
        title: User ID Not Found
        message: The provided user ID does not exist in our records.
    Error0006:
      summary: Internal Server Error
      value:
        code: IDE-0006
        title: Internal Server Error
        message: The server encountered an unexpected error. Please try again later.
    Error0045:
      summary: MFA Operation Failed
      value:
        code: IDE-0045
        title: MFA Operation Failed
        message: >-
          The MFA operation failed due to an unexpected error. Please try again
          later.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: The authorization token in the 'Bearer <token>' format.

````