Begin two-factor enrolment.
POST
/api/auth/two-factor/enrol
const url = 'https://api.tradr.cloud/api/auth/two-factor/enrol';const options = {method: 'POST'};
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://api.tradr.cloud/api/auth/two-factor/enrolGenerates a fresh TOTP secret (at least 160 bits), stores it only as an encryption envelope in a pending row and returns the base32 secret and its otpauth:// URI once, for display as a text key and a QR code. Nothing turns on until POST /two-factor/enrol/confirm accepts a code. Requires an authenticated session; rate limited to 10 management writes per 15 minutes per user; never cached.
Responses
Section titled “ Responses ”The enrolment secret and provisioning URI.
Media typeapplication/json
object
otpauthUri
The otpauth:// provisioning URI for a QR code.
string
secret
The base32 TOTP secret (text key).
string
Examplegenerated
{ "otpauthUri": "example", "secret": "example"}No authenticated session.
Two-factor is already enabled (TWO_FACTOR_ALREADY_ENABLED).
Rate limit exceeded.