Skip to main content

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​

  1. 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. The assigned_teams, assigned_keys, access_mcp_servers and access_agents lists carry the readable name next to each id, and name is null when the id no longer resolves.

  2. 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}, or GET /v1/access_group for every group.

    curl http://localhost:4000/v1/access_group/ag-3f9c -H "Authorization: Bearer $SPANWAY_API_KEY"
  3. 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"]
    }'
  4. Attach a key directly. Give a key the group with access_group_ids on /key/generate or /key/update, or send the key's hash in assigned_key_ids on the group. A non admin team member may set access_group_ids on 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"]}'
  5. 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​

ChangeTableAction and values
A group is created, updated or deletedSpanway_AccessGroupTablecreated, updated or deleted, with the group before and after
A team, key or agent gains or loses the group because of that changeSpanway_TeamTable, Spanway_VerificationToken, Spanway_AgentsTableupdated, with access_group_ids before and after
A model rename or delete rewrites the group's model namesSpanway_AccessGroupTableupdated, 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.

MethodPathSummary
GET/v1/access_groupList access groups
POST/v1/access_groupCreate 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 messageCauseFix
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 existsAnother group has that name.Pick a different access_group_name, or update the existing group.
404 Access group 'ag-...' not foundThe 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_nameThe 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 deleteThe 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 groupThe 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​

LevelLineMeaningAction
ERRORdelete_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.
DEBUGCould 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.