/auth/login/second-factor
0.1.0Unchanged since publicationComplete sign-in with an authenticator app code or a recovery code
noneSubmit the challenge from POST /auth/login with code for an authenticator app code or recovery_code for a recovery code. If both are supplied, UrbeStack uses recovery_code. The selected code must contain 1 to 40 characters drawn from word characters, spaces, and hyphens.
The challenge is valid for this step only and expires after two minutes or on the fifth wrong code. It must be submitted from the IP address that started sign-in. Presenting it from another IP address invalidates it. A successful request consumes the challenge and any recovery code used, then returns token, expires_at, and user. The session is bound to that same IP address. UrbeStack records up to 255 characters from User-Agent for the session list when the client sends it.
A blocked client IP address or an invalid code returns 401. An invalid or expired challenge, a challenge for an inactive account, or a fifth wrong code also returns 401 and directs the client to restart at POST /auth/login. A request that passes the login policy check but lacks a client IP address returns 500. Wrong codes count as failed sign-ins for both ban rules and the login policy. Ten wrong codes flag the client IP address just as ten wrong passwords do.
As a command
Run as root on the serverchallengestring, up to 64 charactersRequiredcodestring, up to 16 charactersrecovery_codestring, up to 40 charactersExample
See the API overview for how to set $API and $TOKEN.curl -sS -X POST "$API/auth/login/second-factor" \
-H "Content-Type: application/json" \
-d '{
"challenge": "text",
"code": "text",
"recovery_code": "text"
}'200 OK{
"challenge": "text",
"enrol_second_factor": true,
"expires_at": "2026-09-16T10:15:00Z",
"second_factor": true,
"token": "ub_9f3c2a7e1b5d4082a6c1e7f0",
"user": {
"backups": true,
"bandwidth_bytes": 1,
"bandwidth_cut": true,
"bandwidth_cut_at": "text",
"bandwidth_limit_bytes": 1,
"created_at": "2026-09-09T10:15:00Z",
"customers": 1,
"disk_limit_bytes": 1,
"email": "alice@example.com",
"home": "text",
"id": 1,
"move_state": "leaving",
"name": "alice",
"owner": "text",
"owner_id": 1,
"package": "basic",
"package_backups": true,
"package_id": 1,
"package_shell": true,
"role": "user",
"second_factor": true,
"shell": true,
"status": "active",
"system_password": true,
"uid": 1
}
}Errors
19 errors, each a status and a sentence400A <kind> token needs the client's address400A plugin's token names its scopes400A session is opened by a panel user: name one with --actor400A session opened for a user is a session400Invalid <what>: expected a non-negative integer400Invalid IPv4 address400Invalid IPv6 address400Invalid id400Invalid label: 1 to 64 printable ASCII characters400Invalid user agent: 1 to 255 printable ASCII characters400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter400Username '<value>' is reserved401Challenge expired; sign in again401Invalid code403<opener.name> may not open the panel of <owner>403Only a customer's panel is opened: <owner> is an administrator403User '<owner>' is suspended404Token <id> not found404User 'urbestack.com/docs/api/post-auth-login-second-factor/