Get your free beta license ↗
API operation · auth group
POST

/auth/second-factor/recovery-codes

First published 14 Oct 20260.2.0Unchanged since publication

Replace the caller's second-factor recovery codes

Who may call it
AdministratorResellerCustomer
Token scope, any of
all
Answers200 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 server

Request body

JSON ·CurrentPassword· 1 field
current_passwordstring, up to 128 charactersRequired

Example

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 sentence
400--name is required
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400Username '<value>' is reserved
401Authentication required
404User '<name>' not found
409User '<name>' has no second factor; the recovery codes come with turning one on
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/