UI Session API
This page documents the 8 gateway endpoints tagged UI Session in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| POST | /session/logout | Sign out of the Admin UI |
| GET | /session/me | Who the Admin UI session belongs to |
| GET | /user/mfa | Two-factor status of the signed-in user |
| POST | /user/mfa/enroll | Start setting up an authenticator app |
| POST | /user/mfa/enroll/confirm | Finish two-factor setup with a code |
| POST | /user/mfa/disable | Turn off two-factor sign-in |
| POST | /user/mfa/recovery_codes | Replace your recovery codes |
| POST | /user/mfa/reset | Reset a user's two-factor sign-in |
Endpoints
POST /session/logout
Sign out of the Admin UI
Sign the caller out of the Admin UI for real: the session key created at sign-in is deleted on the server and
the session cookie is cleared, so a copied cookie or token stops working at once instead of at the end of
SPANWAY_UI_SESSION_DURATION.
Any signed-in Admin UI user may call it for their own session. Only an Admin UI session key is accepted, any
other key gets 403, so this route can never delete an ordinary virtual key. Only the session presented is
revoked, the user's sessions in other browsers stay signed in. The deleted session key is recorded like any other
deleted key. Calling it again for a session that is already gone answers Session already revoked.
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/session/logout" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json SessionLogoutResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The request used a key that is not an Admin UI session key | application/json ErrorDetail |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
GET /session/me
Who the Admin UI session belongs to
Tell the Admin UI who is signed in: the user id, email and role, how they signed in, whether they must change
their password, and when the session ends (expires_at, in Unix seconds). The session key itself is never
returned.
The session cookie cannot be read by page scripts, so the Admin UI asks here instead. It answers only when the request authenticated with the key inside that same cookie, any other key or a missing cookie gets 401. Nothing is changed.
Example request:
curl -X GET "http://localhost:4000/session/me" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json SessionInfoResponse |
| 401 | No dashboard session cookie matches the credential this request used | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | User Id |
user_email | string or null | Yes | User Email |
user_role | string | Yes | User Role |
login_method | enum: "sso", "username_password" | Yes | Login Method |
premium_user | boolean | Yes | Premium User |
disabled_non_admin_personal_key_creation | boolean | Yes | Disabled Non Admin Personal Key Creation |
password_reset_required | boolean | Yes | Password Reset Required |
auth_header_name | string | Yes | Auth Header Name |
expires_at | integer | Yes | Expires At |
GET /user/mfa
Two-factor status of the signed-in user
Whether the signed-in user has two-factor sign-in set up, whether it is required for them, and how many recovery codes they have left.
Example request:
curl -X GET "http://localhost:4000/user/mfa" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaStatus |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
enrolled | boolean | Yes | Enrolled |
required | boolean | Yes | Required |
recovery_codes_remaining | integer | Yes | Recovery Codes Remaining |
POST /user/mfa/enroll
Start setting up an authenticator app
Start setting up an authenticator app for the signed-in user. Returns the otpauth URI to show as a QR code and the secret for manual entry. Nothing is enforced until /user/mfa/enroll/confirm accepts a code.
Request body (application/json, schema MfaEnrollRequest):
| Field | Type | Required | Description |
|---|
Example request:
curl -X POST "http://localhost:4000/user/mfa/enroll" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaEnrollment |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
otpauth_uri | string | Yes | Otpauth Uri |
secret | string | Yes | Secret |
POST /user/mfa/enroll/confirm
Finish two-factor setup with a code
Finish setting up the authenticator app with a current code. Returns ten single-use recovery codes, shown only this once.
Request body (application/json, schema MfaCodeRequest):
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Code |
Example request:
curl -X POST "http://localhost:4000/user/mfa/enroll/confirm" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "123456"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaRecoveryCodes |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
recovery_codes | array of string | Yes | Recovery Codes |
POST /user/mfa/disable
Turn off two-factor sign-in
Turn off two-factor sign-in for the signed-in user with a current code. Refused while it is required for them globally or by one of their organizations.
Request body (application/json, schema MfaCodeRequest):
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Code |
Example request:
curl -X POST "http://localhost:4000/user/mfa/disable" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "123456"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaChanged |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
POST /user/mfa/recovery_codes
Replace your recovery codes
Replace the signed-in user's recovery codes with ten new ones, given a current code. The old codes stop working.
Request body (application/json, schema MfaCodeRequest):
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Code |
Example request:
curl -X POST "http://localhost:4000/user/mfa/recovery_codes" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "123456"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaRecoveryCodes |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
recovery_codes | array of string | Yes | Recovery Codes |
POST /user/mfa/reset
Reset a user's two-factor sign-in
Proxy admins only. Remove a user's two-factor setup and sign them out of every Admin UI session, for a user who lost their authenticator and recovery codes. If two-factor sign-in is required for them they set it up again at their next sign-in.
Request body (application/json, schema MfaResetRequest):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | User Id |
Example request:
curl -X POST "http://localhost:4000/user/mfa/reset" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json MfaChanged |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |