# POST /auth/second-factor

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

UrbeStack release 0.2.35 API operation in the auth group.

Start enrolment of the caller's second factor

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

Supply current_password to start TOTP enrolment. The response contains the new secret as text and as an otpauth:// URI. Add the secret to an authenticator app, then send a code from the app to POST /auth/second-factor/confirm. The factor stays pending until confirmation.

Starting enrolment again replaces the pending secret. To replace a confirmed factor, first disable it with POST /auth/second-factor/disable.

## As a command

- [urbestack-user-second-factor-enrol](https://urbestack.com/docs/commands/urbestack-user-second-factor-enrol.md): Starts enrolment of a TOTP second factor and prints the secret as text and as an otpauth:// URI for an authenticator app.

## Request body

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

- `current_password` (string, up to 128 characters, required)

## 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" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "current_password": "text"
  }'
```

Response, 200 OK:

```
{
  "account": "text",
  "issuer": "text",
  "pending": true,
  "secret": "text",
  "uri": "text"
}
```

## Errors

- 400: --name is required
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Username '<value>' is reserved
- 401: Authentication required
- 404: User '<name>' not found
- 409: User '<name>' already has a second factor; turn it off first
