Confirm email codes
const url = 'https://api.emite.cr/v1/auth/2fa/email/confirm';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"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/email/confirm \ --header 'Content-Type: application/json' \ --data '{ "code": "123456" }'Confirms the 6-digit code sent by POST /v1/auth/2fa/email/enable and turns on the email-code method: from then on, signing in asks for a code sent to the account email. 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. 400 INVALID_CODE or CODE_EXPIRED, 429 TOO_MANY_ATTEMPTS after five attempts on the same code, 409 TWO_FACTOR_ALREADY_ENABLED when the method is already active.
Request Bodyrequired
Section titled “Request Bodyrequired”object
6-digit code sent to the account email.
Example
123456Responses
Section titled “Responses”Email codes are 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" ]}