Skip to content

Teams & Space Grants

A team is a group of users in your organization. A space grant gives a team Read or Write on a space and on every space below it. Together they let you give people access to one part of the space tree and nothing else, which the organization-wide roles of Identity & Access cannot do.

What a Member sees and can do in the granted spaces, surface by surface, is described in Space Access.

How access is decided

  • Grants are additive. A user's access to a space is the highest of their organization role and every grant their teams hold on that space or on a space above it. There are no deny rules: a grant can only add access.
  • A grant covers the subtree. A grant on a space applies to that space and every space below it. A grant on the root space applies to the whole organization.
  • The Member role is the boundary. A user with the Read role still reads every space, whatever their grants; a Write grant on one space adds Write there. To limit someone to part of the tree, give them the Member role: a Member reaches only the spaces their teams are granted.
  • Teams of one. Grants are given to teams, not to users. To give one person access, make a team with only them in it.
  • Changes apply on the next request. Adding or removing a member, changing or removing a grant, and deleting a team or a space take effect from the user's next request, without signing in again.

What a Write grant covers

Within the granted spaces, a Write grant covers what a user with the Write role does to stacks, runs, bundles and spaces there: triggering, approving and cancelling runs, changing a stack's source, triggers and variables, attaching bundles, and creating and editing spaces. A Read grant covers viewing them.

A grant never covers organization administration, which stays with the Admin role: users and invitations, teams and grants, API keys of other users, source control and cloud integrations, plan policies, webhooks, worker pools, organization settings, the audit log, state rollback and releasing a state lock.

Source control integrations are managed by Admins. A Write grant lets a Member bind a stack only to an integration scoped to the stack's space or a space above it, or to an organization-wide one.

Managing teams

Teams and grants are managed by Admins. Every user with the Read role or above can list them.

Action API
List, view teams GET /api/v1/teams, GET /api/v1/teams/{team_id}
Create a team POST /api/v1/teams with name and slug (optional description)
Rename a team, change its description PATCH /api/v1/teams/{team_id}
Delete a team DELETE /api/v1/teams/{team_id}
List members GET /api/v1/teams/{team_id}/members
Add a member POST /api/v1/teams/{team_id}/members with user_id
Remove a member DELETE /api/v1/teams/{team_id}/members/{user_id}

A team's slug is lowercase letters, numbers and hyphens, unique in the organization and fixed once the team exists. A member must be an active user of the organization; a user can belong to several teams. Teams do not nest.

Deleting a team removes its members and its grants. Removing a user from the organization removes them from every team.

Space grants

Action API
List the grants on a space GET /api/v1/spaces/{space_id}/grants
View one team's grant GET /api/v1/spaces/{space_id}/grants/{team_id}
Grant a team a role POST /api/v1/spaces/{space_id}/grants with team_id and role (read or write)
Change the role PATCH /api/v1/spaces/{space_id}/grants/{team_id} with role
Remove the grant DELETE /api/v1/spaces/{space_id}/grants/{team_id}

A team has at most one grant per space. Deleting a space removes the grants on it.

Errors

Status Error code Meaning
409 access_boundaries_inactive Teams, grants and the Member role are switched off on this Zenfra instance by its operator; team, grant and Member changes are refused
409 duplicate_team_slug Another team in the organization has that slug
409 duplicate_membership The user is already in the team
409 duplicate_grant The team already has a grant on the space; change its role instead
400 invalid_role A grant role other than read or write
403 insufficient_role A change by a user who is not an Admin
404 not_found The team, space, grant or user does not exist in your organization

Terraform

The Terraform provider manages teams, members and grants with zenfra_team, zenfra_team_membership and zenfra_space_grant:

resource "zenfra_team" "platform" {
  name = "Platform"
  slug = "platform"
}

resource "zenfra_team_membership" "alice" {
  team_id = zenfra_team.platform.id
  user_id = var.alice_user_id
}

resource "zenfra_space_grant" "platform_networking" {
  space_id = zenfra_space.networking.id
  team_id  = zenfra_team.platform.id
  role     = "write"
}

Audit log

Every change is recorded in the audit log: team.created, team.updated, team.deleted, team.member_added, team.member_removed, space_grant.created, space_grant.updated and space_grant.deleted.