Generate Recovery Codes API
On this page
This API is used to generate a list of Recovery Codes. When creating new codes, any existing Recovery Codes will be cleared and the new set will become the current values.
Request#
Generate a new set of Recovery Codes for a User by their Id, replacing any existing codes.
OpenAPI Spec
Path Parameters#
userIdThe unique Id of the user to assign the generated Recovery Codes to.
Response#
The response for this API contains an array of Recovery Codes that were created. In both standard and FIPS modes, 10 codes are returned. In standard mode, codes use the format XXXXX-XXXXX. In FIPS mode, codes use the format XXXXXXX-XXXXXXX.
The returned codes are the only time they are available in plaintext — they are hashed at rest and cannot be retrieved afterward. Store them securely and provide them to the user immediately. Since 1.68.0.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | The request has no valid Authorization header. The header is missing, or the API key isn't valid. The response is empty. For more information, see Authentication. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
Response Body#
recoveryCodesThe array of Recovery Codes.
{
"code": "752185",
"recoveryCodes": [
"QJD73-L6GR5",
"R7RJH-GB7H3",
"JJ5YZ-KS4C3",
"CRDHP-7L355",
"928QS-P9HMJ",
"8VLFT-Z2WMM",
"PQZX9-YV5VR",
"TK9TB-7BT6H",
"6QYPL-ZPQJV",
"VJ35W-98RW4"
]
}Related
API documentation for the FusionAuth Retrieve Recovery Codes API.
API documentation for the FusionAuth Disable Multi-Factor API.
API documentation for the FusionAuth Enable Multi-Factor API.
API documentation for the FusionAuth Generate a Secret API.