Skip to content

Regenerate recovery codes

POST
/v1/auth/2fa/recovery-codes/regenerate
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.

Media typeapplication/json
object
password
required

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

string
code

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.

string
Examplegenerated
{
"password": "example",
"code": "example"
}

The new recovery codes, returned this one time.

Media typeapplication/json
object
recoveryCodes
required

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.

Array<string>
Example
{
"recoveryCodes": [
"k7m2-p9qx-4hzt",
"a3vb-8wnr-c6je"
]
}