Skip to content

Start replacing the authenticator

POST
/v1/auth/2fa/totp/replace
curl --request POST \
--url https://api.emite.cr/v1/auth/2fa/totp/replace \
--header 'Content-Type: application/json' \
--data '{ "password": "example", "code": "123456" }'

Requires the current password AND a code from the current authenticator, and returns the new one: otpauthUrl, qrCodeDataUrl and manualKey, as in POST /v1/auth/2fa/totp/setup. The current authenticator keeps working until the new one is confirmed at POST /v1/auth/2fa/totp/replace/confirm, within 15 minutes; if that never happens, nothing changes. Starting again replaces the pending one. 409 TWO_FACTOR_NOT_ENABLED without an active authenticator; 400 INVALID_TWO_FACTOR_CODE for a wrong code.

Media typeapplication/json
object
password
required

The current password of the account. A wrong one answers 400 INVALID_CURRENT_PASSWORD.

string
code
required

A code from the authenticator being replaced.

string
Example
123456

The new authenticator, waiting for its first code.

Media typeapplication/json
object
otpauthUrl
required

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.

string
qrCodeDataUrl
required

The same URI as a QR code: a PNG data URL, 256 pixels wide, usable directly as the src of an <img>.

string
manualKey
required

The secret in base32, in groups of four separated by spaces: for typing it into the app when the QR cannot be scanned.

string
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"
}