Internal User management API
This page documents the 11 gateway endpoints tagged Internal User management 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 | /user/new | Create an internal user |
| GET | /user/info | Get a user with their keys and teams |
| GET | /v2/user/info | Get a user's profile and limits |
| POST | /user/update | Update an internal user |
| POST | /user/bulk_update | Update several users at once |
| GET | /user/list | List internal users |
| POST | /user/delete | Delete internal users |
| POST | /user/password/change | Change your own password |
| POST | /management/v1/users/bulk | Create several users at once |
| POST | /management/v1/users/bulk_delete | Delete several users at once |
| GET | /user/available_users | Seats used and remaining under the license |
Endpoints
POST /user/new
Create an internal user
Creates a person who can sign in to the Admin UI and call models, with an optional budget, model list and teams, and by default a first key. Proxy admins and organization admins may call it, and only proxy admins may create proxy admins or admin viewers. The new user is written to the audit log.
Use this to create a new INTERNAL user with a budget. Internal Users can access Spanway Admin UI to make keys, request access to models. This creates a new user and generates a new api key for the new user. The new api key is returned.
Returns user id, budget + new key.
What to send:
user_id: Specify a user id. If not set, a unique id will be generated.user_alias: A descriptive name for you to know who this user id refers to.teams: specify a list of team id's a user belongs to.user_email: Specify a user email.send_invite_email: Specify if an invite email should be sent.user_role: One of "proxy_admin", "proxy_admin_viewer", "internal_user" or "internal_user_viewer". See https://docs.spanway.ai/docs/proxy/users#rolesmax_budget: Specify max budget for a given user.budget_duration: Budget is reset at the end of specified duration. If not set, budget is never reset. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo").models: Model_name's a user is allowed to call. (if empty, key is allowed to call all models). Set to ['no-default-models'] to block all model access. Restricting user to only team-based model access.tpm_limit: Specify tpm limit for a given user (Tokens per minute)rpm_limit: Specify rpm limit for a given user (Requests per minute)auto_create_key: Default=True. Flag used for returning a key as part of the /user/new responsealiases: Model aliases for the user - Docsconfig: [DEPRECATED PARAM] User-specific config.allowed_cache_controls: List of allowed cache control values. Example - ["no-cache", "no-store"]. See all values - https://docs.spanway.ai/docs/proxy/caching#turn-on--off-caching-per-requestblocked: Stored for compatibility, but the gateway does not act on it for users. Block the user's keys instead.guardrails: Stored for compatibility, but the gateway does not act on it for users.policies: List of policy names to apply to the user. Policies define guardrails, conditions, and inheritance rules.permissions: Stored for compatibility, but the gateway does not act on it for users.metadata: Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app": "app2", "email": "user@example.com" }max_parallel_requests: Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x.model_max_budget: Model-specific max budget for user. Docsbudget_fallbacks: Per-model fallback chain tried in order when that model's ownmodel_max_budgetis exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}.model_rpm_limit: Model-specific rpm limit for user. Docsmcp_rpm_limit: Per-MCP-server rpm limit, keyed by MCP server name {"jira": 100, "slack": 200}. Enforced for keys and teams only; values set on a user are stored but not enforced per user.tag_rpm_limit: Per-request-tag rpm limit, keyed by request tag {"cell-1": 1000, "cell-2": 500}. Enforced for keys only; values set on a user are stored but not enforced per user.model_tpm_limit: Model-specific tpm limit for user. Docsspend: Amount spent by user. Default is 0. Will be updated by proxy whenever user is used. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo").agent_id: The agent id associated with the user.team_id: [DEPRECATED PARAM] The team id of the user. Default is None.duration: Duration for the key auto-created on/user/new. Default is None.key_alias: Alias for the key auto-created on/user/new. Default is None.sso_user_id: The id of the user in the SSO provider.object_permission: internal user-specific object permission. Example - {"vector_stores": ["vector_store_1"], "mcp_servers": ["jira"], "mcp_tool_permissions": {"jira": ["list_issues"]}}. The MCP grants act as a ceiling on every key this user holds. IF null or {} then no object permission.prompts: List of allowed prompts for the user. If specified, the user will only be able to use these specific prompts.organizations: List of organization id's the user is a member ofbudget_limits: List of concurrent budget windows for the user. Each window specifies a budget_limit, time_period, and optional budget_duration. Example - [{"budget_limit": 10.0, "time_period": "1d"}, {"budget_limit": 50.0, "time_period": "7d"}].password: Not supported; any value is rejected with a 422. Users set their own password through an invitation link (POST /invitation/new). What you get back:key: The generated API key for the userexpires: When the key expires.user_id: Unique user id, used for tracking spend across multiple keys for the same user.max_budget: Max budget for the user, or null for no limit.
Usage Example
curl -X POST "http://localhost:4000/user/new" -H "Content-Type: application/json" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -d '{
"user_email": "dev@example.com",
"user_role": "internal_user",
"max_budget": 25,
"budget_duration": "30d"
}'
Request body (application/json, schema NewUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
key_alias | string or null | No | Key Alias |
duration | string or null | No | Duration |
models | array of any or null | No | Models |
spend | number or null | No | Spend |
max_budget | number or null | No | Max Budget |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
agent_id | string or null | No | Agent Id |
max_parallel_requests | integer or null | No | Most requests that may run at the same time. One more gets a 429. Empty means no cap. |
metadata | object or null | No | Metadata |
tpm_limit | integer or null | No | Most tokens per minute. Going over gets a 429. Empty means no cap. |
rpm_limit | integer or null | No | Most requests per minute. Going over gets a 429. Empty means no cap. |
budget_duration | string or null | No | Budget Duration |
budget_limits | array of BudgetLimitEntry or null | No | Budget Limits |
allowed_cache_controls | array of any or null | No | Allowed Cache Controls |
config | object or null | No | Config |
permissions | object or null | No | Stored for compatibility, but the gateway does not act on it for users. |
model_max_budget | object or null | No | Model Max Budget |
budget_fallbacks | object or null | No | Budget Fallbacks |
model_rpm_limit | object or null | No | Requests per minute for each model, as model name to a whole number |
model_tpm_limit | object or null | No | Tokens per minute for each model, as model name to a whole number |
mcp_rpm_limit | object or null | No | Mcp Rpm Limit |
tag_rpm_limit | object or null | No | Tag Rpm Limit |
guardrails | array of string or null | No | Stored for compatibility, but the gateway does not act on it for users. |
policies | array of string or null | No | Policies |
prompts | array of string or null | No | Prompts |
blocked | boolean or null | No | Stored for compatibility, but the gateway does not act on it for users. |
aliases | object or null | No | Aliases |
object_permission | Spanway_ObjectPermissionBase or null | No | |
user_email | string or null | No | User Email |
user_alias | string or null | No | User Alias |
user_role | enum: "proxy_admin", "proxy_admin_viewer", "internal_user", "internal_user_viewer" or null | No | User Role |
teams | array of string or array of NewUserRequestTeam or null | No | Teams |
auto_create_key | boolean | No | Auto Create Key |
send_invite_email | boolean or null | No | Send Invite Email |
sso_user_id | string or null | No | Sso User Id |
organizations | array of string or null | No | Organizations |
password | string or null | No | Password |
Example request:
curl -X POST "http://localhost:4000/user/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_email": "dev@example.com",
"user_role": "internal_user",
"max_budget": 25,
"budget_duration": "30d",
"models": [
"claude-sonnet-5-5"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json NewUserResponse |
| 400 | A field breaks a rule, or the gateway has no database | application/json ProxyError |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The license allows no more users, or only proxy admins may create administrative users | application/json ProxyError |
| 409 | Another user already has that user_id or email | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database or another step failed unexpectedly. The gateway log has the cause | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
key_alias | string or null | No | Key Alias |
duration | string or null | No | Duration |
models | array of any or null | No | Models |
spend | number or null | No | Spend |
max_budget | number or null | No | Max Budget |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
agent_id | string or null | No | Agent Id |
max_parallel_requests | integer or null | No | Most requests that may run at the same time. One more gets a 429. Empty means no cap. |
metadata | object or null | No | Metadata |
tpm_limit | integer or null | No | Most tokens per minute. Going over gets a 429. Empty means no cap. |
rpm_limit | integer or null | No | Most requests per minute. Going over gets a 429. Empty means no cap. |
budget_duration | string or null | No | Budget Duration |
budget_limits | array of BudgetLimitEntry or null | No | Budget Limits |
allowed_cache_controls | array of any or null | No | Allowed Cache Controls |
config | object or null | No | Config |
permissions | object or null | No | Permissions |
model_max_budget | object or null | No | Model Max Budget |
budget_fallbacks | object or null | No | Budget Fallbacks |
model_rpm_limit | object or null | No | Requests per minute for each model, as model name to a whole number |
model_tpm_limit | object or null | No | Tokens per minute for each model, as model name to a whole number |
mcp_rpm_limit | object or null | No | Mcp Rpm Limit |
tag_rpm_limit | object or null | No | Tag Rpm Limit |
guardrails | array of string or null | No | Guardrails |
policies | array of string or null | No | Policies |
prompts | array of string or null | No | Prompts |
blocked | boolean or null | No | Blocked |
aliases | object or null | No | Aliases |
object_permission | Spanway_ObjectPermissionBase or null | No | |
key | string | Yes | Key |
tpd_limit | integer or null | No | Tpd Limit |
default_estimated_output_tokens | integer or null | No | Default Estimated Output Tokens |
default_estimated_output_tokens_per_model | object or null | No | Default Estimated Output Tokens Per Model |
budget_id | string or null | No | Budget Id |
end_user_budget_id | string or null | No | End User Budget Id |
tags | array of string or null | No | Tags |
disable_global_guardrails | boolean or null | No | Disable Global Guardrails |
enable_prompt_caching | boolean or null | No | Enable Prompt Caching |
provider_preferences | object or null | No | Provider Preferences |
data_policy | object or null | No | Data Policy |
throttle_on_budget_exceeded | boolean or null | No | Throttle On Budget Exceeded |
enforced_params | array of string or null | No | Enforced Params |
allowed_routes | array of any or null | No | Allowed Routes |
allowed_passthrough_routes | array of any or null | No | Allowed Passthrough Routes |
denied_passthrough_routes | array of string or null | No | Denied Passthrough Routes |
allowed_ips | array of string or null | No | Allowed Ips |
allowed_vector_store_indexes | array of AllowedVectorStoreIndexItem or null | No | Allowed Vector Store Indexes |
rpm_limit_type | enum: "guaranteed_throughput", "best_effort_throughput", "dynamic" or null | No | guaranteed refuses limits above the team's, dynamic enforces only on model errors |
tpm_limit_type | enum: "guaranteed_throughput", "best_effort_throughput", "dynamic" or null | No | guaranteed refuses limits above the team's, dynamic enforces only on model errors |
router_settings | UpdateRouterConfig or null | No | |
access_group_ids | array of string or null | No | Access Group Ids |
key_name | string or null | No | Key Name |
key_type | string or null | No | Key Type |
expires | string or null | No | Expires |
token_id | string or null | No | Token Id |
organization_id | string or null | No | Organization Id |
project_id | string or null | No | Project Id |
spanway_budget_table | any or null | No | Spanway Budget Table |
token | string or null | No | Token |
created_by | string or null | No | Created By |
updated_by | string or null | No | Updated By |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
user_email | string or null | No | User Email |
user_role | enum: "proxy_admin", "proxy_admin_viewer", "internal_user", "internal_user_viewer" or null | No | User Role |
teams | array of any or null | No | Teams |
user_alias | string or null | No | User Alias |
GET /user/info
Get a user with their keys and teams
Shows one internal user with their settings, spend, keys and teams. Leave user_id out to read your own user;
admins may read anyone, and proxy admins who leave it out get every user. Other keys may only read their own
user. Use /user/list to page through users. Nothing changes.
Example request
curl -X GET 'http://localhost:4000/user/info?user_id=user%40example.com' --header "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
user_id | query | string or null | No | User ID in the request parameters |
Example request:
curl -X GET "http://localhost:4000/user/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json UserInfoResponse |
| 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 |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string or null | Yes | User Id |
user_info | object or BaseModel or null | Yes | User Info |
keys | array of any | Yes | Keys |
teams | array of any | Yes | Teams |
GET /v2/user/info
Get a user's profile and limits
Shows one user's profile, spend and limits without their keys or team objects, which makes it fast enough for pages that show many users. Admins may read anyone and other keys only their own user. Nothing changes.
Lightweight endpoint to get user info. Returns only the user object, without keys or team objects.
This is the v2 replacement for /user/info, designed to avoid the "god endpoint" problem where the old endpoint loaded all keys and teams into memory.
Note on spend: this is the user's running budget counter, which the budget reset job
resets whenever budget_reset_at elapses (see budget_duration): to zero by default,
or to the overage above max_budget when budget_rollover is enabled. It is NOT
lifetime or per-period historical spend. For historical spend over a date range, use
/user/daily/activity or /user/daily/activity/aggregated, which read daily spend
records that only ever accumulate and are never reset. The two values are expected to
diverge once a budget reset has occurred within the queried period.
Access control:
- Proxy admins can query any user
- Team admins can query users within their teams
- Internal users can only query themselves (omit user_id or pass own)
- Returns 404 for non-existent users or unauthorized access
Example request:
curl -X GET 'http://localhost:4000/v2/user/info?user_id=user123' \
--header "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
user_id | query | string or null | No | User ID in the request parameters |
Example request:
curl -X GET "http://localhost:4000/v2/user/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json UserInfoV2Response |
| 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 |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | User Id |
user_email | string or null | No | User Email |
user_alias | string or null | No | User Alias |
user_role | string or null | No | User Role |
custom_role_id | string or null | No | Custom Role Id |
spend | number | No | Spend |
max_budget | number or null | No | Max Budget |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
max_parallel_requests | integer or null | No | Max Parallel Requests |
models | array of string | No | Models |
policies | array of string | No | Policies |
budget_duration | string or null | No | Budget Duration |
budget_reset_at | string or null | No | Budget Reset At |
metadata | object or null | No | Metadata |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
sso_user_id | string or null | No | Sso User Id |
teams | array of string | No | Teams |
object_permission | Spanway_ObjectPermissionTable or null | No | |
model_max_budget | object or null | No | Model Max Budget |
model_max_budget_usage | object or null | No | Model Max Budget Usage |
POST /user/update
Update an internal user
Change an internal user's role, budget, models or other settings. Fields you leave out keep their stored value.
curl --location 'http://0.0.0.0:4000/user/update' --header "Authorization: Bearer $SPANWAY_MASTER_KEY" --header 'Content-Type: application/json' --data '{
"user_id": "test-spanway-user-4",
"user_role": "proxy_admin_viewer"
}'
What to send:
- user_id: Specify a user id. If not set, a unique id will be generated.
- user_email: Specify a user email.
- password: Set the user's password (admin only). Must satisfy the configured password policy. The user is
required to change it at their next login. Users change their own password with POST /user/password/change.
- user_alias: A descriptive name for you to know who this user id refers to.
- teams: specify a list of team id's a user belongs to.
- send_invite_email: Specify if an invite email should be sent.
- user_role: One of "proxy_admin", "proxy_admin_viewer", "internal_user" or "internal_user_viewer". See
https://docs.spanway.ai/docs/proxy/users#roles
- max_budget: Specify max budget for a given user.
- budget_duration: Budget is reset at the end of specified duration. If not set, budget is never reset. You
can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo").
- models: Model_name's a user is allowed to call. (if empty, key is allowed to call all models)
- tpm_limit: Specify tpm limit for a given user (Tokens per minute)
- rpm_limit: Specify rpm limit for a given user (Requests per minute)
- auto_create_key: Default=True. Flag used for returning a key as part of the /user/new response
- aliases: Model aliases for the user - Docs
- config: [DEPRECATED PARAM] User-specific config.
- allowed_cache_controls: List of allowed cache control values.
Example - ["no-cache", "no-store"]. See all values - https://docs.spanway.ai/docs/proxy/caching#turn-on--off-caching-per-request
- blocked: Stored for compatibility, but the gateway does not act on it for users. Block the user's keys
instead.
- guardrails: Stored for compatibility, but the gateway does not act on it for users.
- policies: List of policy names to apply to the user. Policies define guardrails, conditions, and
inheritance rules.
- permissions: Stored for compatibility, but the gateway does not act on it for users.
- metadata: Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app":
"app2", "email": "user@example.com" }
- max_parallel_requests: Rate limit a user based on the number of parallel requests. Raises 429 error, if
user's parallel requests > x.
- model_max_budget: Model-specific max budget for user.
Docs
- budget_fallbacks: Per-model fallback chain tried in order when that model's own model_max_budget is
exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}.
- model_rpm_limit: Model-specific rpm limit for user.
Docs
- mcp_rpm_limit: Per-MCP-server rpm limit, keyed by MCP server name {"jira": 100, "slack": 200}. Enforced
for keys and teams only; values set on a user are stored but not enforced per user.
- tag_rpm_limit: Per-request-tag rpm limit, keyed by request tag {"cell-1": 1000, "cell-2": 500}. Enforced
for keys only; values set on a user are stored but not enforced per user.
- model_tpm_limit: Model-specific tpm limit for user.
Docs
- spend: Amount spent by user. Default is 0. Will be updated by proxy whenever user is used. You can set
duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"), months ("1mo").
- agent_id: The agent id associated with the user.
- team_id: [DEPRECATED PARAM] The team id of the user. Default is None.
- object_permission: internal user-specific object permission. Example - {"vector_stores":
["vector_store_1"], "mcp_servers": ["jira"], "mcp_tool_permissions": {"jira": ["list_issues"]}}. The MCP
grants act as a ceiling on every key this user holds. IF null or {} then no object permission.
- prompts: List of allowed prompts for the user. If specified, the user will only be able to use these
specific prompts.
- budget_limits: List of concurrent budget windows for the user. Each window specifies a budget_limit,
time_period, and optional budget_duration. Example - [{"budget_limit": 10.0, "time_period": "1d"},
{"budget_limit": 50.0, "time_period": "7d"}].
Request body (application/json, schema UpdateUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
key_alias | string or null | No | Key Alias |
duration | string or null | No | Duration |
models | array of any or null | No | Models |
spend | number or null | No | Spend |
max_budget | number or null | No | Max Budget |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
agent_id | string or null | No | Agent Id |
max_parallel_requests | integer or null | No | Most requests that may run at the same time. One more gets a 429. Empty means no cap. |
metadata | object or null | No | Metadata |
tpm_limit | integer or null | No | Most tokens per minute. Going over gets a 429. Empty means no cap. |
rpm_limit | integer or null | No | Most requests per minute. Going over gets a 429. Empty means no cap. |
budget_duration | string or null | No | Budget Duration |
budget_limits | array of BudgetLimitEntry or null | No | Budget Limits |
allowed_cache_controls | array of any or null | No | Allowed Cache Controls |
config | object or null | No | Config |
permissions | object or null | No | Stored for compatibility, but the gateway does not act on it for users. |
model_max_budget | object or null | No | Model Max Budget |
budget_fallbacks | object or null | No | Budget Fallbacks |
model_rpm_limit | object or null | No | Requests per minute for each model, as model name to a whole number |
model_tpm_limit | object or null | No | Tokens per minute for each model, as model name to a whole number |
mcp_rpm_limit | object or null | No | Mcp Rpm Limit |
tag_rpm_limit | object or null | No | Tag Rpm Limit |
guardrails | array of string or null | No | Stored for compatibility, but the gateway does not act on it for users. |
policies | array of string or null | No | Policies |
prompts | array of string or null | No | Prompts |
blocked | boolean or null | No | Stored for compatibility, but the gateway does not act on it for users. |
aliases | object or null | No | Aliases |
object_permission | Spanway_ObjectPermissionBase or null | No | |
password | string or null | No | Password |
user_alias | string or null | No | User Alias |
user_role | enum: "proxy_admin", "proxy_admin_viewer", "internal_user", "internal_user_viewer" or null | No | User Role |
user_email | string or null | No | User Email |
Example request:
curl -X POST "http://localhost:4000/user/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123",
"user_role": "internal_user",
"max_budget": 50
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The user after the update | application/json UserUpdateResponse |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 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 |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | The id of the updated user |
data | Spanway_UserTable | Yes | The user after the update, without the password |
POST /user/bulk_update
Update several users at once
Changes several users in one request, for example raising everyone's budget, either one entry per user or the same change for every user. Proxy admins and organization admins may call it, for the users they may change. Each user is updated on its own, so one failure does not stop the others, and every change is written to the audit log.
Bulk update multiple users at once.
This endpoint allows updating multiple users in a single request. Each user update is processed independently - if some updates fail, others will still succeed.
What to send:
users: List of specific user update requestsall_users: Set to true to update all users in the systemuser_updates: Updates to apply when all_users=True
What you get back:
results: of individual update results- total_requested: Total number of users requested for update
- successful_updates: Number of successful updates
- failed_updates: Number of failed updates
Example request for specific users:
curl --location 'http://0.0.0.0:4000/user/bulk_update' --header "Authorization: Bearer $SPANWAY_MASTER_KEY" --header 'Content-Type: application/json' --data '{
"users": [
{
"user_id": "user1",
"user_role": "internal_user",
"max_budget": 100.0
},
{
"user_email": "user2@example.com",
"user_role": "internal_user_viewer",
"max_budget": 50.0
}
]
}'
Example request for all users:
curl --location 'http://0.0.0.0:4000/user/bulk_update' --header "Authorization: Bearer $SPANWAY_MASTER_KEY" --header 'Content-Type: application/json' --data '{
"all_users": true,
"user_updates": {
"user_role": "internal_user",
"max_budget": 50.0
}
}'
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability |
Request body (application/json, schema BulkUpdateUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
users | array of UpdateUserRequest or null | No | Users |
all_users | boolean or null | No | All Users |
user_updates | UpdateUserRequestNoUserIDorEmail or null | No |
Example request:
curl -X POST "http://localhost:4000/user/bulk_update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"users": [
{
"user_id": "user-123",
"max_budget": 50
},
{
"user_id": "user-456",
"max_budget": 50
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json BulkUpdateUserResponse |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 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 |
| 500 | The database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of UserUpdateResult | Yes | Results |
total_requested | integer | Yes | Total Requested |
successful_updates | integer | Yes | Successful Updates |
failed_updates | integer | Yes | Failed Updates |
GET /user/list
List internal users
Pages through internal users with their spend, limits and key counts, filtered by role, team, organization or a search term. Proxy admins and admin viewers see every user, and organization admins the users of their organizations. Nothing changes.
Get a paginated list of users with filtering and sorting options.
What to send:
role
Filter users by role. Can be one of:
- proxy_admin
- proxy_admin_viewer
- internal_user
- internal_user_viewer
user_ids
Get list of users by user_ids. Comma separated list of user_ids.
sso_ids
Get list of users by sso_ids. Comma separated list of sso_ids.
user_email
Filter users by partial email match
search
Combined search: matches users whose user_id or user_email contains the value (case-insensitive)
team
Filter users by team id. Will match if user has this team in their teams array.
page
The page number to return
page_size
The number of items per page
sort_by
Column to sort by (e.g. 'user_id', 'user_email', 'created_at', 'spend')
sort_order
Sort order ('asc' or 'desc')
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
role | query | string or null | No | Filter users by role |
user_ids | query | string or null | No | Get list of users by user_ids |
sso_user_ids | query | string or null | No | Get list of users by sso_user_id |
user_email | query | string or null | No | Filter users by partial email match |
search | query | string or null | No | Combined search: matches users whose 'user_id' or 'user_email' contains the value (case-insensitive). |
team | query | string or null | No | Filter users by team id |
page | query | integer | No | Page number |
page_size | query | integer | No | Number of items per page |
sort_by | query | string or null | No | Column to sort by (e.g. 'user_id', 'user_email', 'created_at', 'spend') |
sort_order | query | string | No | Sort order ('asc' or 'desc') |
organization_ids | query | string or null | No | Filter users by organization membership. Comma-separated list of org IDs. |
Example request:
curl -X GET "http://localhost:4000/user/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json UserListResponse |
| 400 | sort_by or sort_order is not one the list accepts | application/json ErrorDetail |
| 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 |
| 500 | The database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
users | array of Spanway_UserTableWithKeyCount | Yes | Users |
total | integer | Yes | Total |
page | integer | Yes | Page |
page_size | integer | Yes | Page Size |
total_pages | integer | Yes | Total Pages |
POST /user/delete
Delete internal users
Deletes internal users together with their keys, invitation links and organization and team memberships, so they can no longer sign in or call models. Proxy admins may delete any user; organization admins only users of their organizations. Each deletion is written to the audit log when audit logging is on. Returns how many users were deleted.
curl --location 'http://0.0.0.0:4000/user/delete'
--header "Authorization: Bearer $SPANWAY_MASTER_KEY"
--header 'Content-Type: application/json'
--data-raw '{
"user_ids": ["45e3e396-ee08-4a61-a88e-16b3ce7e0849"]
}'
What to send:
user_ids: The list of user id's to be deleted.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability |
Request body (application/json, schema DeleteUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
user_ids | array of string | Yes | User Ids |
Example request:
curl -X POST "http://localhost:4000/user/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_ids": [
"user-123"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | How many users were deleted | application/json integer |
| 400 | No user id was sent | application/json ErrorDetail |
| 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 |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected | application/json ErrorDetail |
POST /user/password/change
Change your own password
Change the calling user's own password.
Use it when you sign in to the Admin UI with a username and password and want a new password. Only callable
with the dashboard session issued by a username/password
login; SSO sessions and virtual keys are rejected with 403. Requires the
current password. The new password must differ from the
current one and satisfy the configured password policy
(general_settings.password_policy_*: minimum length, character classes,
and, when enabled, breached-password screening via haveibeenpwned.com).
A successful change lifts any pending forced password reset
(password_reset_required) on the account, signs out every other dashboard session of the user, and writes
an audit log entry that names the changed field but never the password.
What to send:
current_password: The user's current password.new_password: The password to change to.
Request body (application/json, schema ChangePasswordRequest):
| Field | Type | Required | Description |
|---|---|---|---|
current_password | string | Yes | Current Password |
new_password | string | Yes | New Password |
Example request:
curl -X POST "http://localhost:4000/user/password/change" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"current_password": "old-passphrase-2025",
"new_password": "longer-new-passphrase-2026"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The password was changed and every other dashboard session was signed out | application/json ChangePasswordResponse |
| 400 | Current password is incorrect. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Passwords can only be changed from a dashboard session created by logging in with a password. | application/json ErrorDetail |
| 422 | A field failed validation and the detail names it | application/json ErrorDetail |
| 500 | DB not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | User Id |
message | string | Yes | Message |
POST /management/v1/users/bulk
Create several users at once
Create up to 500 internal users in one request, optionally adding each one to teams, for example when onboarding a whole department. Proxy admins may create any user; organization and team admins only users they may grant the requested roles and teams to. Each created user is written to the audit log.
Every entry in users takes the same fields as /user/new, with two differences: auto_create_key
defaults to false (opt in per user to also get a virtual key back) and send_invite_email is not
supported. Unknown fields are rejected with 422. Rows are validated together (duplicate ids or emails,
unknown teams, roles the caller may not grant), inserted in one statement, and each referenced team is
written once for all of its new members.
Rows fail independently: a bad row is reported in data with success: false and an error, and the
other rows still get created. A user that was created but could not be added to one of its teams is
reported with success: true, teams listing where they did land, and error naming the failed team.
The whole request is refused with a 403 problem document only if creating the valid rows would exceed
the license seat limit.
Example curl:
curl -X POST "http://localhost:4000/management/v1/users/bulk" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-d '{
"users": [
{"user_email": "a@example.com", "user_role": "internal_user", "teams": ["team-1"]},
{"user_email": "b@example.com", "user_role": "internal_user", "auto_create_key": true}
]
}'
Returns data (one entry per input row, in order, with user_id, user_email, success, teams,
key, error) and meta with total_requested, created and failed.
Request body (application/json, schema BulkNewUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
users | array of BulkNewUserItem | Yes | Users |
Example request:
curl -X POST "http://localhost:4000/management/v1/users/bulk" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"users": [
{
"user_email": "ana@example.com",
"user_role": "internal_user"
},
{
"user_email": "ben@example.com",
"user_role": "internal_user"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One result per input row, in order, and the totals | application/json BulkNewUserResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Creating the valid rows would exceed the license seat limit, served as application/problem+json | application/json ProblemDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database rejected the write, served as application/problem+json | application/json ProblemDetail |
| 503 | The gateway has no database connected, served as application/problem+json | application/json ProblemDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of UserCreateResult | Yes | Data |
meta | BulkNewUserMeta | Yes |
POST /management/v1/users/bulk_delete
Delete several users at once
Delete up to 500 users in one call, taking each out of every team it belongs to, for example when people
leave the company. Each deletion is written to the audit log.
Same authorization as /user/delete: proxy admins may delete anyone, org admins
only users inside organizations they administer. Unknown body fields are a 422.
data holds one result per requested user_id, in request order. A row is
success: false with an error when the id is unknown, repeated in the request,
or outside the caller's scope. Rows that pass those checks are deleted together,
in one transaction, so either all of them go or none does.
Example curl:
curl --location 'http://0.0.0.0:4000/management/v1/users/bulk_delete' --header "Authorization: Bearer $SPANWAY_MASTER_KEY" --header 'Content-Type: application/json' --data '{"user_ids": ["user-1", "user-2"]}'
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | Who the caller is acting for; recorded on the audit log entries this call writes. |
Request body (application/json, schema BulkDeleteUserRequest):
| Field | Type | Required | Description |
|---|---|---|---|
user_ids | array of string | Yes | User Ids |
Example request:
curl -X POST "http://localhost:4000/management/v1/users/bulk_delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_ids": [
"user-123",
"user-456"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One result per requested user id, in request order | application/json BulkDeleteUsersResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not delete users, served as application/problem+json | application/json ProblemDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database rejected the delete, served as application/problem+json | application/json ProblemDetail |
| 503 | The gateway has no database connected, served as application/problem+json | application/json ProblemDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of UserDeleteResult | Yes | Data |
GET /user/available_users
Seats used and remaining under the license
How many internal users and teams the license allows, how many exist, and how many more can be created. A limit that the license does not set is null. Needs an enterprise license.
Example request:
curl -X GET "http://localhost:4000/user/available_users" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json AvailableUsersResponse |
| 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 |
|---|---|---|---|
total_users | integer or null | Yes | Total Users |
total_users_used | integer | Yes | Total Users Used |
total_users_remaining | integer or null | Yes | Total Users Remaining |
total_teams | integer or null | Yes | Total Teams |
total_teams_used | integer | Yes | Total Teams Used |
total_teams_remaining | integer or null | Yes | Total Teams Remaining |