Grant a sudo-mode window by verifying a TOTP or recovery code
POST/api/auth/sudo/totp
sudoTotp
Authenticated (session-cookie) endpoint. Verifies a 6-digit TOTP code (or a single-use recovery code) and stamps `sessions.sudo_until = now() + 5min` — the counterpart to `/api/auth/sudo/password` for OAuth-claimed / passwordless accounts whose only step-up credential is their authenticator. A wrong/absent code returns `401 { error: "invalid_credentials" }` (no oracle on which factors an account holds). Bearer-PAT callers can't sudo (it's a session-row column) → 400. Per-session rate limit: 5 attempts per 15 min → `429 Too Many Requests` with `Retry-After`.
Requires authentication using a session cookie — see tokens and scopes.
curl
curl -X POST 'https://neosource.dev/api/auth/sudo/totp' \
-b 'ns_session=$NEOSOURCE_SESSION' \
-H 'Content-Type: application/json' \
-d '{"code":"123456"}'fetch
fetch("https://neosource.dev/api/auth/sudo/totp", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
body: JSON.stringify({"code":"123456"}),
});Request bodyrequired
application/json
Responses
200Sudo granted; window expires at `sudo_until`
application/json
Standard errors
Bodies documented once for the whole API — see standard errors.
- 400Bearer-token caller has no session to grant sudo on
- 401Authentication required
- 429Rate limited — retry after the `Retry-After` header
- 500Internal server error
- 503Service temporarily unavailable / at capacity — retry after the `Retry-After` header
- 504Gateway timeout — the request exceeded the server's handling budget