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

# Enable 2FA

> Enable two-factor authentication after verifying the TOTP code.



## OpenAPI

````yaml POST /user/2fa/enable
openapi: 3.1.0
info:
  title: FormBnB API
  version: 1.0.0
  description: API for FormBnB - Form backend as a service
servers:
  - url: https://api.formbnb.com
security: []
paths:
  /user/2fa/enable:
    post:
      tags:
        - User
        - 2FA
      summary: Enable 2FA
      description: Enable two-factor authentication after verifying the TOTP code.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Enable2FARequest'
      responses:
        '200':
          description: 2FA enabled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserSuccessResponse'
        '400':
          description: Invalid code or 2FA already enabled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserErrorResponse'
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    Enable2FARequest:
      type: object
      properties:
        code:
          type: string
          minLength: 6
          maxLength: 6
          pattern: ^\d+$
          description: TOTP code from authenticator app
      required:
        - code
    UserSuccessResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
      required:
        - success
    UserErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or API Key
      description: >-
        Authentication using either a FormBnB session JWT (issued by /auth) or
        an API key (prefixed with sk_). Both token types are passed as Bearer
        tokens in the Authorization header.

````