API operation · auth group
POST
/auth/second-factor/recovery-codes
First published 14 Oct 2026
0.2.0Unchanged since publicationReplace the caller's second-factor recovery codes
Who may call it
AdministratorResellerCustomer
Token scope, any of
allAnswers200 OK
Supply current_password and authenticate with a session or API token that has the all scope. The operation returns 409 if the caller has no confirmed second factor. POST /auth/second-factor/confirm returns the initial recovery codes.
All previous recovery codes stop working immediately. The response contains eight new single-use recovery codes, shown only once. Each code can replace an authenticator app code for one sign-in.
As a command
Run as root on the servercurrent_passwordstring, up to 128 charactersRequiredExample
See the API overview for how to set $API and $TOKEN.Request
curl -sS -X POST "$API/auth/second-factor/recovery-codes" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"current_password": "text"
}'Response ·
200 OK{
"enabled": true,
"recovery_codes": [
"text"
],
"recovery_codes_left": 1
}Errors
6 errors, each a status and a sentence400--name is required400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter400Username '<value>' is reserved401Authentication required404User '<name>' not found409User '<name>' has no second factor; the recovery codes come with turning one onNo error of this operation matches.
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.2.0 on 14 Oct 2026.
urbestack.com/docs/api/post-auth-second-factor-recovery-codes/