Delete a team membership
Removes a user from a team, and revokes the user's grants that are limited to that team.
The caller needs the admin role on the team's project. The user keeps
their sessions and tokens, but they no longer carry the team's roles.
The request is idempotent. Removing a user who is not a member, or who was
already removed, answers 204 and changes nothing. A change sends a
team.membership.updated event, and an authz.revoked event for each
revoked grant.
Removing the last active member of a team that owns a project is refused
with 409 proj.last_owner, which names those projects: add another member
to the team with createTeamMembership (POST /teams/{team_id}/memberships),
then try again.
Removing a member ends the roles the team gave them, so it is held to the
rule of createTeamMembership
(ADR 094 §7):
for a team of the deployment's platform project, the caller must hold, on
every project the team owns or holds a grant on, at least the role it
gives (reason target_holds_more), and from a team that owns a project
only one of its active members or an operator removes a member (reason
owning_team_members_only), both answering 403 team.permission_denied.
AuthorizationBearer <token>Scope: team_membership.delete
team_id*stringThe team ID: the id that createTeam (POST /teams) or queryTeams (POST /teams/query) returns.
^[a-zA-Z0-9_-]+$user_id*stringThe user ID: the id that createUser (POST /users) or queryUsers (POST /users/query) returns.
^user_[a-zA-Z0-9_-]+$The user is not a member of the team.
import { createZitadelApi } from "@zitadel/api/client";import { configureZitadel, getApi } from "@zitadel/api/config";// In the browser, through the SDK proxy: the session cookie authenticates the call.const session = getApi(configureZitadel({ projectId: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" }));// A write the session cookie authenticates carries the session's CSRF token.const { csrf_token } = await session.getMySessionCsrfToken();const api = createZitadelApi( session.client.with({ fetch: (input, init) => { const headers = new Headers(init?.headers); headers.set("X-Zitadel-CSRF", csrf_token); return fetch(input, { ...init, headers }); }, }),);await api.deleteTeamMembership("team_01KZZY8PX8K8ATNVDSMRCZY4N1", "user_01KWH3B72K7M7F0N9WD3P2E4YM");Was this helpful?