Skip to navigation

Setup 2FA

Generate a new TOTP secret and QR code for setting up two-factor authentication. The user should scan the QR code with their authenticator app, then verify with a code using the Verify 2FA endpoint.

Authentication: Required — Bearer token.

Response:

  • secret — The TOTP secret key (for manual entry if QR scanning fails)
  • qr_svg — SVG markup of the QR code containing the TOTP provisioning URI
  • backup_codes — Array of 8 one-time backup codes (store these securely)

Side effects:

  • Generates and saves a new OTP secret on the user record
  • Generates and saves 8 backup codes
  • Does NOT enable 2FA yet — call Verify 2FA to complete setup

Note: Calling this endpoint again will regenerate the secret, invalidating any previously scanned QR code.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Response

OK