# POST /auth/second-factor/confirm

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the auth group.

Confirm the caller's pending second factor

- Who may call it: administrator, reseller, customer
- Token scope: any
- Answers: 200 OK

Send the six-digit code from the authenticator app in code. Surrounding whitespace is allowed. A missing code or a code in any other format returns 400.

After confirmation, signing in requires a second step. The response contains eight single-use recovery codes, shown only once. Each code can replace an authenticator app code for one sign-in.

On a server that requires a second factor for administrators, confirmation grants the all scope to the session used for the request if that session was opened solely for enrolment and its scopes are still empty. The all scope excludes export, which covers export and import.

## As a command

- [urbestack-user-second-factor-confirm](https://urbestack.com/docs/commands/urbestack-user-second-factor-confirm.md): Confirms a pending second factor using the authenticator app's six-digit code supplied with --code.

## Request body

JSON, the type [SecondFactorConfirm](https://urbestack.com/docs/api/types/SecondFactorConfirm.md).

- `code` (string, up to 16 characters, required): Six-digit code displayed by the authenticator app.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/auth/second-factor/confirm" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "text"
  }'
```

Response, 200 OK:

```
{
  "confirmed_at": "text",
  "enabled": true,
  "recovery_codes": [
    "text"
  ]
}
```

## Errors

- 400: --code is the six digits the app shows
- 400: --name is required
- 400: Invalid id
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: The code does not match; check the secret in the app and the clock of the device
- 400: The code is the six digits the app shows
- 400: Unknown scope '<s>'; the scopes are 
- 400: Username '<value>' is reserved
- 401: Authentication required
- 404: User '<name>' not found
- 409: User '<name>' has no enrolment pending; start one first
