Confirm the authenticator
const url = 'https://api.emite.cr/v1/auth/2fa/totp/confirm';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"password":"example","code":"123456"}'};
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/confirm \ --header 'Content-Type: application/json' \ --data '{ "password": "example", "code": "123456" }'Confirms the authenticator started at POST /v1/auth/2fa/totp/setup with the current password and a live code from it: from then on, signing in asks for it. When it is the first method of the account, the response carries the recovery codes, shown this one time. Closes every OTHER session of the person — they were opened without the second factor. This session continues under a new token, returned in the X-Session-Token header. 409 TWO_FACTOR_SETUP_REQUIRED when no setup was started, 409 TWO_FACTOR_ALREADY_ENABLED when it is already active, 400 INVALID_TWO_FACTOR_CODE for a wrong code.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The current password of the account. A wrong one answers 400 INVALID_CURRENT_PASSWORD.
Current 6-digit code from the authenticator app.
Example
123456Responses
Section titled “Responses”The authenticator is active; recoveryCodes when it is the first method.
object
Present only when this method is the first second factor of the account: the 10 single-use recovery codes (xxxx-xxxx-xxxx), returned this one time — the API keeps only a hash of each. Absent (an empty object) when another method was already active: the existing codes stay as they were.
Example
{ "recoveryCodes": [ "k7m2-p9qx-4hzt", "a3vb-8wnr-c6je" ]}