Regenerate recovery codes
const url = 'https://api.emite.cr/v1/auth/2fa/recovery-codes/regenerate';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"password":"example","code":"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/recovery-codes/regenerate \ --header 'Content-Type: application/json' \ --data '{ "password": "example", "code": "example" }'Replaces the set of recovery codes: the old ones stop working immediately, and the 10 new ones (recoveryCodes, format xxxx-xxxx-xxxx) are returned this one time only. Requires the current password and a second-factor proof in code, as POST /v1/auth/2fa/disable does. 409 TWO_FACTOR_NOT_ENABLED when two-factor authentication is off.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The current password of the account. A wrong one answers 400 INVALID_CURRENT_PASSWORD.
Proof of the second factor, required although the schema marks it optional (400 TWO_FACTOR_CODE_REQUIRED without it): a current code from the authenticator app, an unused recovery code (spent by this call), or, only when email is the sole method of the account, the code sent by POST /v1/auth/2fa/email/management-code. A wrong one answers 400 INVALID_TWO_FACTOR_CODE.
Examplegenerated
{ "password": "example", "code": "example"}Responses
Section titled “Responses”The new recovery codes, returned this one time.
object
The new set of 10 single-use recovery codes (xxxx-xxxx-xxxx), returned this one time: the API keeps only a hash of each, and the previous set no longer works.
Example
{ "recoveryCodes": [ "k7m2-p9qx-4hzt", "a3vb-8wnr-c6je" ]}