Enroll TOTP using an MFA challenge (no JWT required)
const url = 'https://example.com/v1/auth/mfa/enroll-via-challenge';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"challenge_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","action":"generate","code":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/auth/mfa/enroll-via-challenge \ --header 'Content-Type: application/json' \ --data '{ "challenge_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "action": "generate", "code": "example" }'Used when a tenant requires MFA but the user hasn’t enrolled yet. The user receives a challenge_id from VerifyMFAChallenge (enrollment_required=true), then calls this endpoint to generate a TOTP secret, enroll it, and get a JWT. The challenge_id serves as the credential — no JWT is needed.
Request Body required
Section titled “Request Body required ”object
‘generate’ returns a TOTP secret/QR URI. ‘verify’ validates the code and completes enrollment.
TOTP code from the authenticator app. Required when action is verify.
Responses
Section titled “ Responses ”Enrollment step completed.
object
TOTP shared secret for manual entry. Only on generate action.
Otpauth:// URI for QR code. Only on generate action.
Signed JWT. Only on successful verify action.
Backup codes. Only on successful verify action.
Example generated
{ "secret": "example", "qr_uri": "example", "token": "example", "expires_at": "2026-04-15T12:00:00Z", "backup_codes": [ "example" ]}Malformed request or invalid code.
object
Machine-readable error code (e.g. “not_found”, “tenant_mismatch”).
Human-readable description of the error.
Optional additional context about the error.
object
Policy notices from determining Cedar rules, if applicable.
Example generated
{ "code": "example", "message": "example", "details": {}, "notices": [ "example" ]}Challenge not found or expired.
object
Machine-readable error code (e.g. “not_found”, “tenant_mismatch”).
Human-readable description of the error.
Optional additional context about the error.
object
Policy notices from determining Cedar rules, if applicable.
Example generated
{ "code": "example", "message": "example", "details": {}, "notices": [ "example" ]}