Skip to main content

Team member permissions

A team has admins and members. Admins can do everything with the team's keys. What a member may do is decided by the team's member permissions, a list of key management routes the member is allowed to call on keys of that team. By default a member can only read a key and check its health, so they cannot create or change team keys. Turn on the routes you want to allow, per team or for many teams at once, and members get exactly that much freedom with the team's keys. Their own personal keys are not affected.

When you would use this​

The data science team wants every member to create their own keys in the team and update their budgets without asking the team admin, but nobody except admins should delete keys or change what access groups a key carries. You allow /key/generate and /key/update for the team and leave the rest off. Members create and edit keys on the Virtual Keys page, and a member who tries to delete one gets a 403 that names the missing permission.

Before you start​

You need the team id and a proxy admin key, an organization admin of the team's organization, or a team admin session. The full list of permissions you can grant comes back in all_available_permissions from GET /team/permissions_list.

Step by step​

  1. See the current permissions. In the Admin UI open Teams, click the team and open the Member Permissions tab. It lists every key route with its method and description and a checkbox for each. Over the API call GET /team/permissions_list.

    curl "http://localhost:4000/team/permissions_list?team_id=team-ds" -H "Authorization: Bearer $SPANWAY_API_KEY"
    {
    "team_id": "team-ds",
    "team_member_permissions": ["/key/info", "/key/health"],
    "all_available_permissions": [
    "/key/generate",
    "/key/update",
    "/key/delete",
    "/key/info",
    "/key/regenerate",
    "/key/service-account/generate",
    "/key/{key_id}/regenerate",
    "/key/list",
    "/key/block",
    "/key/unblock",
    "/key/bulk_update",
    "/team/key/bulk_update",
    "/key/{key_id}/reset_spend",
    "/key/access_group_assignment",
    "/auto_router/manage",
    "/key/health"
    ]
    }

    team_member_permissions is null for a team that never set any, which means the default of /key/info and /key/health.

  2. Set the permissions for one team. Tick the routes on the Member Permissions tab and click Save Changes. The Admin UI shows "Permissions updated successfully". Over the API send the full list to POST /team/permissions_update. The list replaces the stored one, and /key/info and /key/health are always kept even when you leave them out.

    curl -X POST http://localhost:4000/team/permissions_update \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"team_id": "team-ds", "team_member_permissions": ["/key/generate", "/key/update", "/key/delete", "/key/info", "/key/health"]}'
  3. Add a permission to many teams. A proxy admin can append permissions to a list of teams, or to every team, with POST /team/permissions_bulk_update. The permissions are merged with each team's existing list, so nothing is taken away. Pass team_ids, or apply_to_all_teams: true, not both.

    curl -X POST http://localhost:4000/team/permissions_bulk_update \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"permissions": ["/key/generate", "/key/update"], "team_ids": ["team-ds", "team-nlp"]}'
    {"message": "Team permissions updated successfully", "teams_updated": 2, "permissions_appended": ["/key/generate", "/key/update"]}
  4. Try it as a member. Sign in to the Admin UI as a member of the team, open Virtual Keys, click Create New Key and pick the team. With /key/generate allowed the key is created. Over the API the member's own key or session can call the allowed routes on team keys.

    curl -X POST http://localhost:4000/key/generate \
    -H "Authorization: Bearer $MEMBER_KEY" \
    -H "Content-Type: application/json" \
    -d '{"team_id": "team-ds", "key_alias": "my-experiments"}'

What you should see​

The Member Permissions tab shows the ticked routes, and GET /team/permissions_list returns them in team_member_permissions. A member calling an allowed route on a key of the team succeeds, a member calling a route that is not on the list gets a 403 that names the route and the team, and admins of the team are never limited by the list. Every change writes an audit log row with the list before and after.

Permissions​

PermissionWhat a member may then do
/key/generate, /key/service-account/generateCreate keys, or service account keys, in the team.
/key/update, /key/bulk_update, /team/key/bulk_updateChange keys of the team, one at a time or in bulk.
/key/deleteDelete keys of the team.
/key/regenerate, /key/{key_id}/regenerateRotate a key of the team.
/key/block, /key/unblockBlock and unblock keys of the team.
/key/{key_id}/reset_spendReset the recorded spend of a team key.
/key/list, /key/info, /key/healthList keys of the team, and read and health check a key. /key/info and /key/health are always allowed.
/key/access_group_assignmentSet access_group_ids on keys they create or update. Not a route, a field level permission that is off by default.
/auto_router/manageManage auto routers for the team.

Errors​

ErrorCauseFix
403 Call not allowed. User not proxy admin OR team admin. route=/team/permissions_update, team_id=...The caller is a member, not a proxy admin, organization admin or team admin.Ask a team admin, or use a proxy admin key.
403 Only proxy admins can bulk-update team permissionsA team admin called the bulk route.Use a proxy admin key, or update each team with /team/permissions_update.
400 Must provide team_ids or set apply_to_all_teams=trueThe bulk body named no teams.Add team_ids or apply_to_all_teams: true.
400 Cannot set both apply_to_all_teams=true and team_idsThe bulk body had both.Send one of them.
404 Team not found, passed team_id=...The team id does not exist.Check it with GET /team/list.
422 on permissionsA value is not one of the key management routes.Use a value from all_available_permissions.
A member's key call answers 403 naming a routeThe route is not in the team's list.Add it with /team/permissions_update.