Start authenticator setup
const url = 'https://api.emite.cr/v1/auth/2fa/totp/setup';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"password":"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://api.emite.cr/v1/auth/2fa/totp/setup \ --header 'Content-Type: application/json' \ --data '{ "password": "example" }'Starts TOTP enrollment: generates a secret, stored encrypted and unconfirmed, and returns what an authenticator app needs: the otpauth:// URI (otpauthUrl), the same as a QR code (qrCodeDataUrl, a PNG data URL) and the key for manual entry (manualKey). Requires the current password. Nothing is protected until POST /v1/auth/2fa/totp/confirm confirms it with a code; calling again replaces the unconfirmed secret. 409 TWO_FACTOR_ALREADY_ENABLED when the authenticator is already active (move it to another device with POST /v1/auth/2fa/totp/replace); 403 TWO_FACTOR_DEMO_FORBIDDEN in the demo.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The current password of the account: every change to the second factor asks for it again. A wrong one answers 400 INVALID_CURRENT_PASSWORD.
Examplegenerated
{ "password": "example"}Responses
Section titled “Responses”What an authenticator app needs to add the account.
object
The otpauth:// URI an authenticator app reads (RFC 6238 TOTP: SHA-1, 6 digits, 30-second step), labelled with the account email and issued by EmiteCR. It carries the secret: show it only to the person, and never store it.
The same URI as a QR code: a PNG data URL, 256 pixels wide, usable directly as the src of an <img>.
The secret in base32, in groups of four separated by spaces: for typing it into the app when the QR cannot be scanned.
Example
{ "otpauthUrl": "otpauth://totp/EmiteCR:ventas%40emite.cr?secret=JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP&issuer=EmiteCR", "qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…", "manualKey": "JBSW Y3DP EHPK 3PXP JBSW Y3DP EHPK 3PXP"}