Skip to main content

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.

MethodPathSummary
GET/organization/daily/activity/aggregatedDaily activity per organization
GET/organization/daily/activity/aggregated/keysKeys ranked by spend for a organization
GET/organization/daily/activity/aggregated/searchSearch the keys with activity for a organization
GET/organization/daily/activity/aggregated/model_top_keysTop keys for one model in a organization
GET/organization/daily/activity/exportDownload organization daily activity as CSV or JSON
POST/organization/newCreate an organization
GET/organization/daily/activityDaily spend and usage of an organization
PATCH/organization/updateUpdate an organization
PATCH/v2/organization/{organization_id}Update an organization by id
DELETE/organization/deleteDelete organizations
GET/organization/listList organizations
GET/organization/infoGet an organization with its members and teams
POST/organization/infoGet organizations by id (deprecated)
POST/organization/member_addAdd members to an organization
PATCH/organization/member_updateChange a member's role or budget in an organization
DELETE/organization/member_deleteRemove 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:

NameInTypeRequiredDescription
api_key_limitqueryintegerNoHow many top keys to return
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
exclude_organization_idsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/organization/daily/activity/aggregated" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json SpendAnalyticsPaginatedResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of DailySpendDataYesResults
metadataDailySpendMetadataNo

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:

NameInTypeRequiredDescription
offsetqueryintegerNoHow many rows to skip, for paging
limitqueryintegerNoHow many rows to return
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
exclude_organization_idsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/organization/daily/activity/aggregated/keys" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json DailyActivityKeyPageResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
api_keysarray of KeySpendActivityRowYesApi Keys
total_api_keysintegerYesTotal Api Keys
offsetintegerYesOffset
limitintegerYesLimit

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:

NameInTypeRequiredDescription
searchquerystringYesText to find in key aliases and key hashes
limitqueryintegerNoHow many rows to return
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
exclude_organization_idsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/organization/daily/activity/aggregated/search?search=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json DailyActivityKeySearchResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
api_keysarray of KeyActivityRowYesApi 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:

NameInTypeRequiredDescription
model_groupquerystringYesThe model or model group to rank keys for
by_model_groupquerybooleanNoMatch model_group as a model group, not a model
limitqueryintegerNoHow many rows to return
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
exclude_organization_idsquerystring or nullNo
timezonequeryinteger or nullNo

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:

StatusDescriptionBody
200Successful Responseapplication/json ModelTopKeysResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
modelstringYesModel
by_model_groupbooleanYesBy Model Group
api_keysarray of KeySpendActivityRowYesApi 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:

NameInTypeRequiredDescription
export_typequeryExportTypeNoThe breakdown of each row
formatqueryenum: "csv", "json"Nocsv or json
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
exclude_organization_idsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/organization/daily/activity/export" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Streamed daily activity exporttext/csv string
400Bad Requestapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/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 org
  • tpm_limit: Max tpm limit for org
  • rpm_limit: Max rpm limit for org
  • tpd_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 model
  • budget_duration: Frequency of reseting org budget
  • metadata: 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. Docs
  • object_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):

FieldTypeRequiredDescription
budget_idstring or nullNoBudget Id
soft_budgetnumber or nullNoStored for compatibility, but the gateway does not act on it for organizations.
max_budgetnumber or nullNoMax Budget
max_parallel_requestsinteger or nullNoMost requests all keys of the organization may have running at once. Empty means no cap
tpm_limitinteger or nullNoTpm Limit
rpm_limitinteger or nullNoRpm Limit
tpd_limitinteger or nullNoTpd Limit
model_max_budgetobject or nullNoModel Max Budget
budget_durationstring or nullNoBudget Duration
allowed_modelsarray of string or nullNoAllowed Models
temp_budget_increasenumber or nullNoTemp Budget Increase
temp_budget_expirystring or nullNoTemp Budget Expiry
organization_idstring or nullNoOrganization Id
organization_aliasstringYesOrganization Alias
modelsarray of anyNoModels
metadataobject or nullNoMetadata
model_rpm_limitobject or nullNoModel Rpm Limit
model_tpm_limitobject or nullNoModel Tpm Limit
data_policyobject or nullNoData Policy
require_mfaboolean or nullNoRequire Mfa
object_permissionSpanway_ObjectPermissionBase or nullNo

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:

StatusDescriptionBody
200Successful Responseapplication/json NewOrganizationResponse
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
organization_idstringYesOrganization Id
organization_aliasstring or nullNoOrganization Alias
budget_idstringYesBudget Id
spendnumberNoSpend
metadataobject or nullNoMetadata
modelsarray of stringNoModels
model_spendobject or nullNoModel Spend
created_bystringYesCreated By
updated_bystringYesUpdated By
system_block_reason"billing" or nullNoSystem Block Reason
usersarray of Spanway_UserTable or nullNoUsers
spanway_budget_tableSpanway_BudgetTable or nullNo
object_permissionSpanway_ObjectPermissionTable or nullNo
object_permission_idstring or nullNoObject Permission Id
require_mfabooleanNoRequire Mfa
created_atstringYesCreated At
updated_atstringYesUpdated 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:

NameInTypeRequiredDescription
organization_idsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
pagequeryintegerNo
page_sizequeryintegerNo
exclude_organization_idsquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/organization/daily/activity" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json SpendAnalyticsPaginatedResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
resultsarray of DailySpendDataYesResults
metadataDailySpendMetadataNo

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):

FieldTypeRequiredDescription
budget_idstring or nullNoBudget Id
soft_budgetnumber or nullNoSoft Budget
max_budgetnumber or nullNoMax Budget
max_parallel_requestsinteger or nullNoMax Parallel Requests
tpm_limitinteger or nullNoTpm Limit
rpm_limitinteger or nullNoRpm Limit
tpd_limitinteger or nullNoTpd Limit
model_max_budgetobject or nullNoModel Max Budget
budget_durationstring or nullNoBudget Duration
allowed_modelsarray of string or nullNoAllowed Models
temp_budget_increasenumber or nullNoTemp Budget Increase
temp_budget_expirystring or nullNoTemp Budget Expiry
organization_idstring or nullNoOrganization Id
organization_aliasstring or nullNoOrganization Alias
spendnumber or nullNoSpend
metadataobject or nullNoMetadata
modelsarray of string or nullNoModels
updated_bystring or nullNoUpdated By
object_permissionobject or nullNo
model_tpm_limitobject or nullNoModel Tpm Limit
model_rpm_limitobject or nullNoModel Rpm Limit
require_mfaboolean or nullNoRequire Mfa
data_policyobject or nullNoData 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:

StatusDescriptionBody
200The organization after the updateapplication/json Spanway_OrganizationTableWithMembers
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
organization_idstring or nullNoOrganization Id
organization_aliasstring or nullNoOrganization Alias
budget_idstringYesBudget Id
spendnumberNoSpend
metadataobject or nullNoMetadata
modelsarray of stringNoModels
model_spendobject or nullNoModel Spend
created_bystringYesCreated By
updated_bystringYesUpdated By
system_block_reason"billing" or nullNoSystem Block Reason
usersarray of Spanway_UserTable or nullNoUsers
spanway_budget_tableSpanway_BudgetTable or nullNo
object_permissionSpanway_ObjectPermissionTable or nullNo
object_permission_idstring or nullNoObject Permission Id
require_mfabooleanNoRequire Mfa
membersarray of Spanway_OrganizationMembershipTableNoMembers
teamsarray of Spanway_TeamTableNoTeams
created_atstringYesCreated At
updated_atstringYesUpdated 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:

NameInTypeRequiredDescription
organization_idpathstringYes

Request body (application/json, schema OrganizationUpdateRequestV2):

FieldTypeRequiredDescription
organization_aliasstring or nullNoOrganization Alias
modelsarray of string or nullNoModels
metadataobject or nullNoMetadata
tpm_limitinteger or nullNoTpm Limit
rpm_limitinteger or nullNoRpm Limit
max_budgetnumber or nullNoMax Budget
soft_budgetnumber or nullNoSoft Budget
max_parallel_requestsinteger or nullNoMax Parallel Requests
model_max_budgetobject or nullNoModel Max Budget
budget_durationstring or nullNoBudget Duration
object_permissionSpanway_ObjectPermissionBase or nullNo
require_mfaboolean or nullNoRequire 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:

StatusDescriptionBody
200The organization after the updateapplication/json Spanway_OrganizationTableWithMembers
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
organization_idstring or nullNoOrganization Id
organization_aliasstring or nullNoOrganization Alias
budget_idstringYesBudget Id
spendnumberNoSpend
metadataobject or nullNoMetadata
modelsarray of stringNoModels
model_spendobject or nullNoModel Spend
created_bystringYesCreated By
updated_bystringYesUpdated By
system_block_reason"billing" or nullNoSystem Block Reason
usersarray of Spanway_UserTable or nullNoUsers
spanway_budget_tableSpanway_BudgetTable or nullNo
object_permissionSpanway_ObjectPermissionTable or nullNo
object_permission_idstring or nullNoObject Permission Id
require_mfabooleanNoRequire Mfa
membersarray of Spanway_OrganizationMembershipTableNoMembers
teamsarray of Spanway_TeamTableNoTeams
created_atstringYesCreated At
updated_atstringYesUpdated 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):

FieldTypeRequiredDescription
organization_idsarray of stringYesOrganization 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:

StatusDescriptionBody
200The deleted organizationsapplication/json array of Spanway_OrganizationTableWithMembers
401No valid key was presented, or the caller is not a proxy adminapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/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:

NameInTypeRequiredDescription
org_idquerystring or nullNoFilter organizations by exact organization_id match
org_aliasquerystring or nullNoFilter 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:

StatusDescriptionBody
200The organizations the caller can seeapplication/json array of Spanway_OrganizationTableWithMembers
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
422Validation Errorapplication/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:

NameInTypeRequiredDescription
organization_idquerystringYes

Example request:

curl -X GET "http://localhost:4000/organization/info?organization_id=organization_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_OrganizationTableWithMembers
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
organization_idstring or nullNoOrganization Id
organization_aliasstring or nullNoOrganization Alias
budget_idstringYesBudget Id
spendnumberNoSpend
metadataobject or nullNoMetadata
modelsarray of stringNoModels
model_spendobject or nullNoModel Spend
created_bystringYesCreated By
updated_bystringYesUpdated By
system_block_reason"billing" or nullNoSystem Block Reason
usersarray of Spanway_UserTable or nullNoUsers
spanway_budget_tableSpanway_BudgetTable or nullNo
object_permissionSpanway_ObjectPermissionTable or nullNo
object_permission_idstring or nullNoObject Permission Id
require_mfabooleanNoRequire Mfa
membersarray of Spanway_OrganizationMembershipTableNoMembers
teamsarray of Spanway_TeamTableNoTeams
created_atstringYesCreated At
updated_atstringYesUpdated 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):

FieldTypeRequiredDescription
organizationsarray of stringYesOrganizations

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:

StatusDescriptionBody
200The requested organizationsapplication/json array of Spanway_OrganizationTableWithMembers
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller is not a proxy admin or an admin of this organizationapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/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_id
    • user_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:

  1. Check if organization exists
  2. Creates a new Internal User if the user_id or user_email is not found in Spanway_UserTable
  3. Add Internal User to the Spanway_OrganizationMembership table

Request body (application/json, schema OrganizationMemberAddRequest):

FieldTypeRequiredDescription
memberarray of OrgMember or OrgMemberYesMember
organization_idstringYesOrganization Id
max_budget_in_organizationnumber or nullNoMax 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:

StatusDescriptionBody
200Successful Responseapplication/json OrganizationAddMemberResponse
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
organization_idstringYesOrganization Id
updated_usersarray of Spanway_UserTableYesUpdated Users
updated_organization_membershipsarray of Spanway_OrganizationMembershipTableYesUpdated 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):

FieldTypeRequiredDescription
user_idstring or nullNoUser Id
user_emailstring or nullNoUser Email
organization_idstringYesOrganization Id
max_budget_in_organizationnumber or nullNoMax Budget In Organization
roleSpanwayUserRoles or nullNo

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:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_OrganizationMembershipTable
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller is not a proxy admin or an admin of this organizationapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
user_idstringYesThe member's user id
organization_idstringYesThe organization the user belongs to
user_rolestring or nullNoThe member's role in this organization, e.g. org_admin
spendnumberNoWhat the member has spent inside this organization, in USD
budget_idstring or nullNoThe member's own budget inside this organization
created_atstringYesWhen the user joined the organization
updated_atstringYesWhen the membership last changed
userany or nullNoThe member's user row, when the caller asked to include it
spanway_budget_tableSpanway_BudgetTable or nullNoThe member's budget limits
user_emailstring or nullNoThe 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):

FieldTypeRequiredDescription
user_idstring or nullNoUser Id
user_emailstring or nullNoUser Email
organization_idstringYesOrganization 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:

StatusDescriptionBody
200The membership that was removedapplication/json Spanway_OrganizationMembershipTable
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller is not a proxy admin or an admin of this organizationapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
user_idstringYesThe member's user id
organization_idstringYesThe organization the user belongs to
user_rolestring or nullNoThe member's role in this organization, e.g. org_admin
spendnumberNoWhat the member has spent inside this organization, in USD
budget_idstring or nullNoThe member's own budget inside this organization
created_atstringYesWhen the user joined the organization
updated_atstringYesWhen the membership last changed
userany or nullNoThe member's user row, when the caller asked to include it
spanway_budget_tableSpanway_BudgetTable or nullNoThe member's budget limits
user_emailstring or nullNoThe member's email, copied from the user row