Access groups
An access group is a named bundle of things a caller may use, models, MCP servers and agents. Instead of listing the same models and servers on every key and every team, you put them in a group once and attach the group. A key or team that carries the group can use everything in it, and when you add a model to the group every attached key gets it at once. Groups are managed by proxy admins and read by admin viewers. No license is needed.
When you would use this
The support desk uses one model, one ticketing MCP server and one triage agent, and new support engineers get a key every week. You create a support-tools group with those three things and attach it to the support team. Every key in the team can call the model and the server without anyone editing the key. When the team moves to a newer model, you change the group once and every key follows.
Before you start
You need a proxy admin key or an Admin UI session with the Admin role, and the team ids, key hashes, MCP server ids and agent ids you want to put in the group. GET /team/list, GET /key/list, GET /v1/mcp/server and GET /v1/agents return them.
Step by step
-
Create the group. In the Admin UI open Access Groups under ACCESS CONTROL and click Create Access Group. On the General Info tab fill in Group Name and Description, then pick Allowed Models on the Models tab, Allowed MCP Servers on the MCP Servers tab and Allowed Agents on the Agents tab, and click Create Group. Teams and keys are attached from the API or from their own settings pages, so to attach a team at creation use
POST /v1/access_group.curl -X POST http://localhost:4000/v1/access_group \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"access_group_name": "support-tools","description": "Models and MCP servers the support desk may use","access_model_names": ["claude-haiku-5-5"],"access_mcp_server_ids": ["mcp-ticketing"],"assigned_team_ids": ["team-support"]}'{"access_group_id": "ag-3f9c","access_group_name": "support-tools","description": "Models and MCP servers the support desk may use","access_model_names": ["claude-haiku-5-5"],"access_mcp_server_ids": ["mcp-ticketing"],"access_agent_ids": [],"assigned_team_ids": ["team-support"],"assigned_key_ids": [],"access_mcp_servers": [{"id": "mcp-ticketing", "name": "Ticketing"}],"access_agents": [],"assigned_teams": [{"id": "team-support", "name": "support"}],"assigned_keys": [],"created_at": "2026-11-01T09:00:00Z","created_by": "admin","updated_at": "2026-11-01T09:00:00Z","updated_by": "admin"}The response answers with status
201. Theassigned_teams,assigned_keys,access_mcp_serversandaccess_agentslists carry the readable name next to each id, andnameisnullwhen the id no longer resolves. -
Check the group. Open Access Groups and click the group's ID. Group Details shows the description and who created it, Attached Keys and Attached Teams list what uses the group, and the Models, MCP Servers and Agents tabs list the bundle. Over the API read
GET /v1/access_group/{access_group_id}, orGET /v1/access_groupfor every group.curl http://localhost:4000/v1/access_group/ag-3f9c -H "Authorization: Bearer $SPANWAY_API_KEY" -
Change the group. Click Edit Access Group on the detail view, change a tab and click Save Changes. The dialog sends only the tabs you opened. Over the API send the fields to replace to
PUT /v1/access_group/{access_group_id}. A list you send replaces the stored list, so send the full set of teams you want attached.curl -X PUT http://localhost:4000/v1/access_group/ag-3f9c \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"description": "Models and MCP servers the support desk may use","access_model_names": ["claude-haiku-5-5", "claude-sonnet-5-5"],"assigned_team_ids": ["team-support", "team-success"]}' -
Attach a key directly. Give a key the group with
access_group_idson/key/generateor/key/update, or send the key's hash inassigned_key_idson the group. A non admin team member may setaccess_group_idson their own keys only when the team's member permissions include/key/access_group_assignment, see team member permissions.curl -X POST http://localhost:4000/key/update \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"key": "sk-9f3a2c7e41b8d605", "access_group_ids": ["ag-3f9c"]}' -
Delete a group you no longer need. Open the row menu on Access Groups, click Delete access group and confirm in Delete Access Group. Over the API call
DELETE /v1/access_group/{access_group_id}. The gateway detaches the group from every team, key and agent that used it.curl -X DELETE http://localhost:4000/v1/access_group/ag-3f9c -H "Authorization: Bearer $SPANWAY_API_KEY"
What you should see
The group is listed on Access Groups with counts for models, MCP servers and agents. A request from a key in an attached team for a model in the group succeeds even though the key and the team do not list the model themselves. Listing MCP tools with that key shows the tools of the group's servers. After a change to the group, attached teams and keys see it on their next request, because the gateway updates its cached copies of them. With several gateway instances and no Redis cache, another instance can keep serving its own copy of the group for up to DEFAULT_ACCESS_GROUP_CACHE_TTL seconds (600, ten minutes, by default), so set a lower value or connect Redis when changes must apply everywhere at once. Every create, update and delete is written to the audit log, and so is every team, key and agent the change attaches or detaches, see audit.
Only team ids are checked when you save. Model names, MCP server ids, agent ids and key hashes are stored as sent, so a typo saves without an error and grants nothing. Check the names the group response shows, a resource whose name is null did not resolve.
The /v1/unified_access_group routes are an alias of /v1/access_group with the same bodies and responses, kept for clients that used the older name.
Two kinds of access groups
This page is about access groups that bundle models, MCP servers and agents and are attached to teams and keys, managed with /v1/access_group. The older model access groups are name tags you put on models in the config file or with /access_group/new, and a key or team lists the tag in its models. They are described in access control. Both can be used at the same time.
Audit
| Change | Table | Action and values |
|---|---|---|
| A group is created, updated or deleted | Spanway_AccessGroupTable | created, updated or deleted, with the group before and after |
| A team, key or agent gains or loses the group because of that change | Spanway_TeamTable, Spanway_VerificationToken, Spanway_AgentsTable | updated, with access_group_ids before and after |
| A model rename or delete rewrites the group's model names | Spanway_AccessGroupTable | updated, by the admin who renamed or deleted the model, with the rename or delete before and the new access_model_names after |
Filter the audit log by Table = Access groups to see the group rows.
| Method | Path | Summary |
|---|---|---|
| GET | /v1/access_group | List access groups |
| POST | /v1/access_group | Create an access group |
| GET | /v1/access_group/{access_group_id} | Get an access group |
| PUT | /v1/access_group/{access_group_id} | Update an access group |
| DELETE | /v1/access_group/{access_group_id} | Delete an access group |
Errors
| Status and message | Cause | Fix |
|---|---|---|
403 {"error": "Admin-only endpoint. Not allowed to access this."} | The caller is not a proxy admin (create, update, delete) or not a proxy admin or admin viewer (read). | Use a proxy admin key. |
409 Access group 'support-tools' already exists | Another group has that name. | Pick a different access_group_name, or update the existing group. |
404 Access group 'ag-...' not found | The id in the URL does not exist. | List groups with GET /v1/access_group and use the access_group_id from the list. |
400 Unknown team ids: <ids> | A team in assigned_team_ids does not exist. Nothing was saved. | Check the ids with GET /team/list. |
422 naming access_group_name | The name is blank on create, or null or blank on update. | Send a name, or leave the field out of an update to keep the current name. |
500 {"error": "DB not connected. This endpoint needs a database..."} | The gateway runs without a database. Every route answers this. | Set DATABASE_URL. |
503 DB not connected... on delete | The database failed while the group was being deleted. Nothing was removed. | Check the database, then retry. |
500 Failed to delete access group. Please try again. | The delete failed for another reason. Nothing was removed. | Read the delete_access_group failed log line, then retry. |
| Request with the key is refused for a model in the group | The key or team was attached but the model name in the group does not match the public model_name on the gateway. | Compare the group's access_model_names with GET /v1/models. |
The same messages are in the error reference.
Logs
| Level | Line | Meaning | Action |
|---|---|---|---|
| ERROR | delete_access_group failed: access_group_id=<id> error=<error> | A delete failed and the caller got a 500 or 503. The line carries the stack trace. | Check the database, then retry the delete. |
| DEBUG | Could not fetch access group <id> for resource field <field> | A request's access check could not load a group, so that group granted nothing for the request. | None when the group was just deleted. Otherwise check the database. |
Both lines are in the log reference.
Related
- Access control for model access groups set in the config file and the other ways to limit access.
- Virtual keys for
access_group_idson keys. - Team member permissions for letting members attach groups to their own keys.
- MCP gateway and custom agents for the servers and agents a group can carry.
- Access Groups page for every control on the Admin UI page.