Organization management API
This page documents the 16 gateway endpoints tagged organization 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 |
|---|---|---|
| GET | /organization/daily/activity/aggregated | Daily activity per organization |
| GET | /organization/daily/activity/aggregated/keys | Keys ranked by spend for a organization |
| GET | /organization/daily/activity/aggregated/search | Search the keys with activity for a organization |
| GET | /organization/daily/activity/aggregated/model_top_keys | Top keys for one model in a organization |
| GET | /organization/daily/activity/export | Download organization daily activity as CSV or JSON |
| POST | /organization/new | Create an organization |
| GET | /organization/daily/activity | Daily spend and usage of an organization |
| PATCH | /organization/update | Update an organization |
| PATCH | /v2/organization/{organization_id} | Update an organization by id |
| DELETE | /organization/delete | Delete organizations |
| GET | /organization/list | List organizations |
| GET | /organization/info | Get an organization with its members and teams |
| POST | /organization/info | Get organizations by id (deprecated) |
| POST | /organization/member_add | Add members to an organization |
| PATCH | /organization/member_update | Change a member's role or budget in an organization |
| DELETE | /organization/member_delete | Remove a member from an organization |
Endpoints
GET /organization/daily/activity/aggregated
Daily activity per organization
Spend, tokens and requests per day for each organization between start_date and end_date (YYYY-MM-DD), with a breakdown by model, provider, endpoint and key. Every day in the range is returned in one answer, so there is nothing to page. This is the query behind the organization usage view of the Admin UI. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
api_key_limit | query | integer | No | How many top keys to return |
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
exclude_organization_ids | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity/aggregated" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json SpendAnalyticsPaginatedResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of DailySpendData | Yes | Results |
metadata | DailySpendMetadata | No |
GET /organization/daily/activity/aggregated/keys
Keys ranked by spend for a organization
One page of the virtual keys that spent the most inside the organization scope and date range, with the spend, tokens and request counts of each. offset and limit page through the list and total_api_keys says how many keys there are in all. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
offset | query | integer | No | How many rows to skip, for paging |
limit | query | integer | No | How many rows to return |
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
exclude_organization_ids | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity/aggregated/keys" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json DailyActivityKeyPageResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
api_keys | array of KeySpendActivityRow | Yes | Api Keys |
total_api_keys | integer | Yes | Total Api Keys |
offset | integer | Yes | Offset |
limit | integer | Yes | Limit |
GET /organization/daily/activity/aggregated/search
Search the keys with activity for a organization
Find virtual keys with activity inside the organization scope and date range whose alias, hash, user id or email matches the search text, each with its spend, tokens and request counts. This is the key search box of the Usage page. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
search | query | string | Yes | Text to find in key aliases and key hashes |
limit | query | integer | No | How many rows to return |
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
exclude_organization_ids | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity/aggregated/search?search=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json DailyActivityKeySearchResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
api_keys | array of KeyActivityRow | Yes | Api Keys |
GET /organization/daily/activity/aggregated/model_top_keys
Top keys for one model in a organization
The virtual keys that spent the most on one model inside the organization scope and date range. by_model_group tells whether model was matched as the public model group or as the individual deployment. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_group | query | string | Yes | The model or model group to rank keys for |
by_model_group | query | boolean | No | Match model_group as a model group, not a model |
limit | query | integer | No | How many rows to return |
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
exclude_organization_ids | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity/aggregated/model_top_keys?model_group=claude-sonnet-5-5" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json ModelTopKeysResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
by_model_group | boolean | Yes | By Model Group |
api_keys | array of KeySpendActivityRow | Yes | Api Keys |
GET /organization/daily/activity/export
Download organization daily activity as CSV or JSON
Stream one row per day for each organization in the range, with requests, tokens and spend. export_type picks the breakdown: daily, daily_with_keys, daily_with_models or daily_with_users. format is csv (the default) or json. The file name carries the entity, the range and the breakdown. This is the Export Data dialog of the Usage page. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
export_type | query | ExportType | No | The breakdown of each row |
format | query | enum: "csv", "json" | No | csv or json |
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
exclude_organization_ids | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity/export" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Streamed daily activity export | text/csv string |
| 400 | Bad Request | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
POST /organization/new
Create an organization
Creates an organization, the top level that owns teams, with its own budget and the models its teams may use. Proxy admins only. The organization is written to the audit log.
Allow orgs to own teams
Set org level budgets + model access.
Only admins can create orgs.
Parameters
organization_alias: The name of the organization.models: The models the organization has access to.budget_id: The id for a budget (tpm/rpm/max budget) for the organization. IF NO BUDGET ID - CREATE ONE WITH THESE PARAMS ###max_budget: Max budget for orgtpm_limit: Max tpm limit for orgrpm_limit: Max rpm limit for orgtpd_limit: Max tokens per day stored on the org budget. Batch submissions enforce tpd_limit at the key, team and end user scopes only.model_rpm_limit: The RPM (Requests Per Minute) limit per model for this organization.model_tpm_limit: The TPM (Tokens Per Minute) limit per model for this organization.max_parallel_requests: Most requests all keys of the organization may have running at once. One more gets a 429.soft_budget: Stored for compatibility, but the gateway does not act on it for organizations.model_max_budget: Max budget for a specific modelbudget_duration: Frequency of reseting org budgetmetadata: Metadata for organization, store information for organization. Example metadata - {"extra_info": "some info"}blocked: Flag indicating if the org is blocked or not - will stop all calls from keys with this org_id.tags: Tags for tracking spend and/or doing tag-based routing.organization_id: The organization id of the team. Default is None. Create via/organization/new.model_aliases: Model aliases for the team. Docsobject_permission: organization-specific object permission. Example - {"vector_stores": ["vector_store_1", "vector_store_2"]}. IF null or {} then no object permission.allowed_models: List of models the organization is allowed to access. If not set, defaults to the models field.temp_budget_increase: Stored on the org budget row but only enforced for team member budgets today.temp_budget_expiry: Stored on the org budget row but only enforced for team member budgets today.data_policy: Data policy every request on the organization's keys must satisfy: require_zdr, forbid_training, restrict_code_traffic, scan_content_for_code and allowed_regions. The router drops every deployment that does not meet it. Example - {"require_zdr": true, "allowed_regions": ["eu"]}require_mfa: Require every member of the organization to sign in to the Admin UI with an authenticator app code (TOTP) on top of their password. Members without one set it up at their next sign-in. SSO sign-ins are not affected. Needs the mfa license feature. Case 1: Create new org without a budget_id
curl --location 'http://0.0.0.0:4000/organization/new'
--header "Authorization: Bearer $SPANWAY_MASTER_KEY"
--header 'Content-Type: application/json'
--data '{
"organization_alias": "my-secret-org",
"models": ["model1", "model2"],
"max_budget": 100
}'
Case 2: Create new org with a budget_id
curl --location 'http://0.0.0.0:4000/organization/new'
--header "Authorization: Bearer $SPANWAY_MASTER_KEY"
--header 'Content-Type: application/json'
--data '{
"organization_alias": "my-secret-org",
"models": ["model1", "model2"],
"budget_id": "428eeaa8-f3ac-4e85-a8fb-7dc8d7aa8689"
}'
Request body (application/json, schema NewOrganizationRequest):
| Field | Type | Required | Description |
|---|---|---|---|
budget_id | string or null | No | Budget Id |
soft_budget | number or null | No | Stored for compatibility, but the gateway does not act on it for organizations. |
max_budget | number or null | No | Max Budget |
max_parallel_requests | integer or null | No | Most requests all keys of the organization may have running at once. Empty means no cap |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
tpd_limit | integer or null | No | Tpd Limit |
model_max_budget | object or null | No | Model Max Budget |
budget_duration | string or null | No | Budget Duration |
allowed_models | array of string or null | No | Allowed Models |
temp_budget_increase | number or null | No | Temp Budget Increase |
temp_budget_expiry | string or null | No | Temp Budget Expiry |
organization_id | string or null | No | Organization Id |
organization_alias | string | Yes | Organization Alias |
models | array of any | No | Models |
metadata | object or null | No | Metadata |
model_rpm_limit | object or null | No | Model Rpm Limit |
model_tpm_limit | object or null | No | Model Tpm Limit |
data_policy | object or null | No | Data Policy |
require_mfa | boolean or null | No | Require Mfa |
object_permission | Spanway_ObjectPermissionBase or null | No |
Example request:
curl -X POST "http://localhost:4000/organization/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_alias": "research",
"max_budget": 5000,
"budget_duration": "30d",
"models": [
"claude-sonnet-5-5",
"claude-haiku-5-5"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json NewOrganizationResponse |
| 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 |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
organization_id | string | Yes | Organization Id |
organization_alias | string or null | No | Organization Alias |
budget_id | string | Yes | Budget Id |
spend | number | No | Spend |
metadata | object or null | No | Metadata |
models | array of string | No | Models |
model_spend | object or null | No | Model Spend |
created_by | string | Yes | Created By |
updated_by | string | Yes | Updated By |
system_block_reason | "billing" or null | No | System Block Reason |
users | array of Spanway_UserTable or null | No | Users |
spanway_budget_table | Spanway_BudgetTable or null | No | |
object_permission | Spanway_ObjectPermissionTable or null | No | |
object_permission_id | string or null | No | Object Permission Id |
require_mfa | boolean | No | Require Mfa |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
GET /organization/daily/activity
Daily spend and usage of an organization
Shows spend, tokens and request counts per day for the organizations in organization_ids (comma
separated), between start_date and end_date (YYYY-MM-DD). Proxy admins and admin viewers see every
organization and organization admins only their own. Read only, nothing changes.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
organization_ids | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
page | query | integer | No | |
page_size | query | integer | No | |
exclude_organization_ids | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/organization/daily/activity" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json SpendAnalyticsPaginatedResponse |
| 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 |
|---|---|---|---|
results | array of DailySpendData | Yes | Results |
metadata | DailySpendMetadata | No |
PATCH /organization/update
Update an organization
Changes an organization's name, budget, models, limits or settings; fields left out keep their stored value.
Proxy admins may change every field, while organization admins may only change the name, require_mfa and
metadata of their own organization, and a data_policy they send must match the stored one. The change is
written to the audit log.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
budget_id | string or null | No | Budget Id |
soft_budget | number or null | No | Soft Budget |
max_budget | number or null | No | Max Budget |
max_parallel_requests | integer or null | No | Max Parallel Requests |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
tpd_limit | integer or null | No | Tpd Limit |
model_max_budget | object or null | No | Model Max Budget |
budget_duration | string or null | No | Budget Duration |
allowed_models | array of string or null | No | Allowed Models |
temp_budget_increase | number or null | No | Temp Budget Increase |
temp_budget_expiry | string or null | No | Temp Budget Expiry |
organization_id | string or null | No | Organization Id |
organization_alias | string or null | No | Organization Alias |
spend | number or null | No | Spend |
metadata | object or null | No | Metadata |
models | array of string or null | No | Models |
updated_by | string or null | No | Updated By |
object_permission | object or null | No | |
model_tpm_limit | object or null | No | Model Tpm Limit |
model_rpm_limit | object or null | No | Model Rpm Limit |
require_mfa | boolean or null | No | Require Mfa |
data_policy | object or null | No | Data Policy |
Example request:
curl -X PATCH "http://localhost:4000/organization/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-research",
"max_budget": 8000,
"budget_duration": "30d"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The organization after the update | application/json Spanway_OrganizationTableWithMembers |
| 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 |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
organization_id | string or null | No | Organization Id |
organization_alias | string or null | No | Organization Alias |
budget_id | string | Yes | Budget Id |
spend | number | No | Spend |
metadata | object or null | No | Metadata |
models | array of string | No | Models |
model_spend | object or null | No | Model Spend |
created_by | string | Yes | Created By |
updated_by | string | Yes | Updated By |
system_block_reason | "billing" or null | No | System Block Reason |
users | array of Spanway_UserTable or null | No | Users |
spanway_budget_table | Spanway_BudgetTable or null | No | |
object_permission | Spanway_ObjectPermissionTable or null | No | |
object_permission_id | string or null | No | Object Permission Id |
require_mfa | boolean | No | Require Mfa |
members | array of Spanway_OrganizationMembershipTable | No | Members |
teams | array of Spanway_TeamTable | No | Teams |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
PATCH /v2/organization/{organization_id}
Update an organization by id
Changes only the fields sent for the organization named in the path and leaves the others untouched, so a script can change one setting without reading the whole organization first. Proxy admins may change every field and organization admins the fields their role allows. The change is written to the audit log.
Partial update of an organization (RESTful PATCH, RFC 7396 merge-patch semantics).
A sent field is written and an omitted one is left untouched (presence is read from
model_fields_set). Clear tokens are per field: budget limits and metadata clear with
null, models with [], and object_permission with null (it merges when sent,
so an empty {} is rejected). organization_alias is required and cannot be cleared.
Validation failures return 422; the object-permission upsert, budget-row write, and
org-row write are one transaction.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
organization_id | path | string | Yes |
Request body (application/json, schema OrganizationUpdateRequestV2):
| Field | Type | Required | Description |
|---|---|---|---|
organization_alias | string or null | No | Organization Alias |
models | array of string or null | No | Models |
metadata | object or null | No | Metadata |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
max_budget | number or null | No | Max Budget |
soft_budget | number or null | No | Soft Budget |
max_parallel_requests | integer or null | No | Max Parallel Requests |
model_max_budget | object or null | No | Model Max Budget |
budget_duration | string or null | No | Budget Duration |
object_permission | Spanway_ObjectPermissionBase or null | No | |
require_mfa | boolean or null | No | Require Mfa |
Example request:
curl -X PATCH "http://localhost:4000/v2/organization/organization_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_alias": "research",
"max_budget": 8000
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The organization after the update | application/json Spanway_OrganizationTableWithMembers |
| 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 |
|---|---|---|---|
organization_id | string or null | No | Organization Id |
organization_alias | string or null | No | Organization Alias |
budget_id | string | Yes | Budget Id |
spend | number | No | Spend |
metadata | object or null | No | Metadata |
models | array of string | No | Models |
model_spend | object or null | No | Model Spend |
created_by | string | Yes | Created By |
updated_by | string | Yes | Updated By |
system_block_reason | "billing" or null | No | System Block Reason |
users | array of Spanway_UserTable or null | No | Users |
spanway_budget_table | Spanway_BudgetTable or null | No | |
object_permission | Spanway_ObjectPermissionTable or null | No | |
object_permission_id | string or null | No | Object Permission Id |
require_mfa | boolean | No | Require Mfa |
members | array of Spanway_OrganizationMembershipTable | No | Members |
teams | array of Spanway_TeamTable | No | Teams |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
DELETE /organization/delete
Delete organizations
Deletes organizations together with their teams, memberships and keys, so every key of the organization stops working at once. Proxy admins only. Each deletion is written to the audit log.
What to send:
organization_ids: The organization ids to delete.
Request body (application/json, schema DeleteOrganizationRequest):
| Field | Type | Required | Description |
|---|---|---|---|
organization_ids | array of string | Yes | Organization Ids |
Example request:
curl -X DELETE "http://localhost:4000/organization/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_ids": [
"org-research"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The deleted organizations | application/json array of Spanway_OrganizationTableWithMembers |
| 401 | No valid key was presented, or the caller is not a proxy admin | 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 |
GET /organization/list
List organizations
Lists organizations with their budgets, members and teams. Proxy admins and admin viewers see every organization; other users only the organizations they belong to. Filter by exact id or by part of the name. Nothing changes.
What to send:
org_id
Filter organizations by exact organization_id match
org_alias
Filter organizations by partial organization_alias match (case-insensitive)
Example:
curl --location --request GET 'http://0.0.0.0:4000/organization/list?org_alias=my-org' --header "Authorization: Bearer $SPANWAY_MASTER_KEY"
Example with org_id:
curl --location --request GET 'http://0.0.0.0:4000/organization/list?org_id=123e4567-e89b-12d3-a456-426614174000' --header "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
org_id | query | string or null | No | Filter organizations by exact organization_id match |
org_alias | query | string or null | No | Filter organizations by partial organization_alias match. Supports case-insensitive search. |
Example request:
curl -X GET "http://localhost:4000/organization/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The organizations the caller can see | application/json array of Spanway_OrganizationTableWithMembers |
| 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 |
GET /organization/info
Get an organization with its members and teams
Shows one organization with its budget, members and teams. Proxy admins and admin viewers may read any organization, and organization admins their own. Nothing changes.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
organization_id | query | string | Yes |
Example request:
curl -X GET "http://localhost:4000/organization/info?organization_id=organization_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_OrganizationTableWithMembers |
| 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 |
|---|---|---|---|
organization_id | string or null | No | Organization Id |
organization_alias | string or null | No | Organization Alias |
budget_id | string | Yes | Budget Id |
spend | number | No | Spend |
metadata | object or null | No | Metadata |
models | array of string | No | Models |
model_spend | object or null | No | Model Spend |
created_by | string | Yes | Created By |
updated_by | string | Yes | Updated By |
system_block_reason | "billing" or null | No | System Block Reason |
users | array of Spanway_UserTable or null | No | Users |
spanway_budget_table | Spanway_BudgetTable or null | No | |
object_permission | Spanway_ObjectPermissionTable or null | No | |
object_permission_id | string or null | No | Object Permission Id |
require_mfa | boolean | No | Require Mfa |
members | array of Spanway_OrganizationMembershipTable | No | Members |
teams | array of Spanway_TeamTable | No | Teams |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
POST /organization/info
Get organizations by id (deprecated)
Returns several organizations with their budgets in one call. Deprecated, use GET /organization/info for one organization or GET /organization/list for several. Proxy admins and admin viewers may read any organization, and organization admins their own. Nothing changes.
Request body (application/json, schema OrganizationRequest):
| Field | Type | Required | Description |
|---|---|---|---|
organizations | array of string | Yes | Organizations |
Example request:
curl -X POST "http://localhost:4000/organization/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organizations": [
"org-research"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The requested organizations | application/json array of Spanway_OrganizationTableWithMembers |
| 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 caller is not a proxy admin or an admin of this organization | application/json ErrorDetail |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
POST /organization/member_add
Add members to an organization
Adds users to an organization by user id or email, with a role and an optional budget inside the organization. A user who does not exist yet is created. Proxy admins and admins of the organization may call it. Each new membership is written to the audit log.
Add new members (either via user_email or user_id) to an organization
If user doesn't exist, new user row will also be added to User Table
Only proxy_admin or org_admin of organization, allowed to access this endpoint.
What to send:
organization_id: (required)member: (required)role: (required)user_iduser_email
Note: Either user_id or user_email must be provided for each member.
Example:
curl -X POST 'http://0.0.0.0:4000/organization/member_add' -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H 'Content-Type: application/json' -d '{
"organization_id": "45e3e396-ee08-4a61-a88e-16b3ce7e0849",
"member": {
"role": "internal_user",
"user_id": "user@example.com"
},
"max_budget_in_organization": 100.0
}'
The following is executed in this function:
- Check if organization exists
- Creates a new Internal User if the user_id or user_email is not found in Spanway_UserTable
- Add Internal User to the
Spanway_OrganizationMembershiptable
Request body (application/json, schema OrganizationMemberAddRequest):
| Field | Type | Required | Description |
|---|---|---|---|
member | array of OrgMember or OrgMember | Yes | Member |
organization_id | string | Yes | Organization Id |
max_budget_in_organization | number or null | No | Max Budget In Organization |
Example request:
curl -X POST "http://localhost:4000/organization/member_add" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-research",
"member": {
"role": "org_admin",
"user_id": "user-123"
},
"max_budget_in_organization": 1000
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json OrganizationAddMemberResponse |
| 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 |
|---|---|---|---|
organization_id | string | Yes | Organization Id |
updated_users | array of Spanway_UserTable | Yes | Updated Users |
updated_organization_memberships | array of Spanway_OrganizationMembershipTable | Yes | Updated Organization Memberships |
PATCH /organization/member_update
Change a member's role or budget in an organization
Changes a member's role or their budget inside an organization, by user id or email. Proxy admins and admins of the organization may call it; nobody but a proxy admin may change a proxy admin. The change is written to the audit log.
Request body (application/json, schema OrganizationMemberUpdateRequest):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string or null | No | User Id |
user_email | string or null | No | User Email |
organization_id | string | Yes | Organization Id |
max_budget_in_organization | number or null | No | Max Budget In Organization |
role | SpanwayUserRoles or null | No |
Example request:
curl -X PATCH "http://localhost:4000/organization/member_update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-research",
"user_id": "user-123",
"role": "internal_user",
"max_budget_in_organization": 500
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_OrganizationMembershipTable |
| 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 caller is not a proxy admin or an admin of this organization | 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 member's user id |
organization_id | string | Yes | The organization the user belongs to |
user_role | string or null | No | The member's role in this organization, e.g. org_admin |
spend | number | No | What the member has spent inside this organization, in USD |
budget_id | string or null | No | The member's own budget inside this organization |
created_at | string | Yes | When the user joined the organization |
updated_at | string | Yes | When the membership last changed |
user | any or null | No | The member's user row, when the caller asked to include it |
spanway_budget_table | Spanway_BudgetTable or null | No | The member's budget limits |
user_email | string or null | No | The member's email, copied from the user row |
DELETE /organization/member_delete
Remove a member from an organization
Removes a user from an organization, by user id or email, so the organization's budget and models no longer apply to them. The user and their keys are kept. Proxy admins and admins of the organization may call it. The removed membership is written to the audit log.
Request body (application/json, schema OrganizationMemberDeleteRequest):
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string or null | No | User Id |
user_email | string or null | No | User Email |
organization_id | string | Yes | Organization Id |
Example request:
curl -X DELETE "http://localhost:4000/organization/member_delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-research",
"user_id": "user-123"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The membership that was removed | application/json Spanway_OrganizationMembershipTable |
| 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 caller is not a proxy admin or an admin of this organization | 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 member's user id |
organization_id | string | Yes | The organization the user belongs to |
user_role | string or null | No | The member's role in this organization, e.g. org_admin |
spend | number | No | What the member has spent inside this organization, in USD |
budget_id | string or null | No | The member's own budget inside this organization |
created_at | string | Yes | When the user joined the organization |
updated_at | string | Yes | When the membership last changed |
user | any or null | No | The member's user row, when the caller asked to include it |
spanway_budget_table | Spanway_BudgetTable or null | No | The member's budget limits |
user_email | string or null | No | The member's email, copied from the user row |