User management hierarchy
Spanway organizes access in layers. Each layer can carry a budget, a model allowlist and rate limits, and a request has to pass the checks of every layer it belongs to. A platform team sets broad limits once at the top, and teams and individuals manage their own keys inside them without being able to exceed them.
Gateway (master key, proxy_admin users)
└── Organization /organization/new
└── Team /team/new
├── Project /project/new
├── Member /team/member_add (role: admin or user)
└── Key /key/generate (team_id, optional user_id, project_id)
When you would use this
The research department gets 1,000 dollars a month across every model it may use. Inside it, the NLP team gets 300 dollars and only the cheap model, and one batch job in that team gets a 50 dollar key. The job is stopped at 50 dollars, the team at 300, and the department at 1,000, whichever comes first, and the NLP team can never pick a model the department did not approve. Nobody has to watch each key.
Layers
Organizations are an enterprise feature. Without a license key the /organization routes return 403, and teams sit directly under the gateway.
| Layer | Created with | Holds | Managed by |
|---|---|---|---|
| Organization | POST /organization/new | Budget, allowed models, member list, org admins | proxy_admin |
| Team | POST /team/new | Budget, models, RPM and TPM limits, members, callbacks, guardrails | proxy_admin, org_admin, team admins |
| Project | POST /project/new | Budget and model limits for a group of keys inside a team | Team admins with the projects permission |
| User | POST /user/new | Role, personal budget, personal models | Admins, or created on SSO sign-in |
| Key | POST /key/generate | Budget, models, limits, metadata | Owner, team admins, admins |
Step by step
-
Create the organization. In the Admin UI open Organizations, click + Create New Organization, fill in Organization Name, Models, Max Budget (USD) and Reset Budget, and click Create Organization. Over the API call
POST /organization/new.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"]}' -
Create a team inside it. Open Teams, click Create Team, fill in Team Name, pick the Organization, choose Models from the organization's list, set Max Budget (USD) and Reset Budget, and click Create Team. Over the API pass
organization_idonPOST /team/new.curl -X POST http://localhost:4000/team/new \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"team_alias": "nlp", "organization_id": "org-research", "max_budget": 300, "models": ["claude-haiku-5-5"]}' -
Add a member. Open the team, open the Members tab, click Add Member, search by Email or User ID, pick the Member Role and click Add Member. Over the API call
POST /team/member_add, withmax_budget_in_teamto cap what that one person may spend on team keys.curl -X POST http://localhost:4000/team/member_add \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"team_id": "team-ds", "member": {"role": "user", "user_id": "user-123"}, "max_budget_in_team": 50}' -
Create a key in the team. Open Virtual Keys, click + Create New Key, pick the Team, type the Key Name and set Max Budget (USD) under Optional Settings. Over the API pass
team_idonPOST /key/generate. Addproject_idto put the key in a project.curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"team_id": "team-ds", "key_alias": "nlp-batch-jobs", "max_budget": 50}' -
Check where a request stands. The Virtual Keys table shows each key's Spend / Budget, and the cell also names the team, organization and user budgets that still limit a key with no budget of its own. The Usage page breaks spend down by organization, team, key and user.
How limits cascade
A request made with a key is checked against the key, then its project, team and organization. The user's personal budget is checked only for keys that belong to no team, unless general_settings.apply_user_budget_to_team_keys is on, in which case team keys count against it too. The request fails at the first layer whose budget is exhausted or whose model list does not include the requested model. Model lists narrow as you go down. A team can only grant models its organization allows, and a key can only use models its team allows. Budgets are independent caps, so a key with a 100 dollar budget in a team with 50 dollars left stops at 50.
Team members can have their own budget inside a team, set with max_budget_in_team on /team/member_add or /team/member_update, which caps one person's spend on team keys without changing the team's total.
What you should see
GET /organization/info?organization_id=org-research lists the organization with its teams and members and its spend. GET /team/info?team_id=team-ds lists the team with its keys and memberships. A request from nlp-batch-jobs for claude-haiku-5-5 succeeds, a request for claude-sonnet-5-5 is refused because the team does not allow it even though the organization does, and once the team has spent 300 dollars every key in it is refused until the reset.
End users
End users (also called customers) are the people your application serves, identified by the user field in a request. They sit outside this hierarchy. You can give them budgets with /customer/new and a budget_id, and spend is reported per end user. They never sign in to the gateway. See customers.
Errors
| Error | Cause | Fix |
|---|---|---|
403 on any /organization route | The gateway has no Spanway license. | Add a license, or create teams directly under the gateway. |
400 naming a model when creating a team | The team's models contains a model the organization does not allow. | Add it to the organization first, or drop it from the team. |
400 about the team budget and the organization | max_budget on the team is above the organization's budget. | Lower the team budget or raise the organization's. |
422 Budget has been exceeded! Team=<id> ..., Project=<id> ... or Organization=<id> ... with type budget_exceeded | A layer above the key spent its budget. The status is 429 when spanway_settings.budget_exceeded_status_code is 429. | Raise that layer's budget or wait for its reset. The message says which layer. |
422 ExceededBudget: User=<id> over budget. ... | The user spent their personal budget on keys outside any team. | Raise the user's budget or wait for its reset. |
403 naming a team and a route | The caller is not an admin of the team or organization. | Ask an admin, or use a proxy admin key. |
404 Team not found or Organization not found | The id in the request does not exist. | Check /team/list and /organization/list. |
Related
- Access control for what each role may change.
- Team budgets for team level spend controls.
- Projects for the layer between teams and keys.
- Users and virtual keys for the bottom layers.
- Organizations page and Teams page for every control on the Admin UI pages.