> ## 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.

# Setup 2FA

> Generate TOTP secret and QR code URL for setting up two-factor authentication.



## OpenAPI

````yaml POST /user/2fa/setup
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/setup:
    post:
      tags:
        - User
        - 2FA
      summary: Set up 2FA
      description: >-
        Generate TOTP secret and QR code URL for setting up two-factor
        authentication.
      responses:
        '200':
          description: 2FA setup information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TwoFactorSetupResponse'
        '400':
          description: 2FA is 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:
    TwoFactorSetupResponse:
      type: object
      properties:
        secret:
          type: string
        otpauthUrl:
          type: string
        backupCodes:
          type: array
          items:
            type: string
      required:
        - secret
        - otpauthUrl
        - backupCodes
    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.

````