Skip to main content
Remove From Subtree
Removes the target user’s direct memberships on this workspace and every descendant you can reach, in one action. An owner (or ancestor owner) reaches the whole subtree via the god-path; a non-owner reaches a descendant when they hold remove-member there — which they may hold either by reaching in through an unbroken open inherit chain, or by holding a direct member row on that node. So sealing (inheritsFromParent = false) stops authority reaching in from above; it does not stop authority held locally. A non-owner who is a direct member of a sealed child with remove-member there does sweep it. The credential does not widen this — actingUserId is required here, so a service key always sweeps as the user it names, with that user’s reach; act as the owner for a full sweep. Reach-based access auto-revokes with the relevant ancestor membership. Each membership-row deletion fires workspace.member.removed. Rank rules apply per node — the sweep is refused (403 workspace/insufficient-rank) if you are outranked by the target at any node where you both hold a direct member row. Owned workspaces — block + report. Because owners have no member row, this sweep cannot offboard a user from a workspace they own. The check covers the whole subtree, including sealed descendants outside your reach, and runs after the rank check:
  • An owned workspace you have standing on always refuses the sweep with 409 workspace/owns-descendants, named in ownedWorkspaces.
  • An owned workspace you have no standing on refuses the sweep only when the target holds a membership this call would remove. It is listed as { id: null, name: null }. When the call would remove nothing (the target is not a member of any workspace you reach), it does not count: you get a 200 with removedCount: 0, and any memberships you can’t reach still show in skipped.
Nothing is removed when the sweep is refused. An owner of each workspace, or an ancestor owner, then reassigns it via transfer-ownership or deletes it, and the sweep can be retried. No silent ownership change.
A non-owner’s sweep may be partial — check skipped before you call someone offboarded. If the target still holds a membership in a descendant you cannot reach, the 200 reports it in skippedCount / skipped. removedCount alone does not mean the user is gone from the subtree: treat any skippedCount > 0 as “still a member somewhere” and escalate to an owner or ancestor owner of that node. Only an owner or ancestor owner is guaranteed skippedCount: 0. A service key is not — it must name an actingUserId on this route, and inherits that user’s reach, so a key acting as a mid-level admin can absolutely come back with skippedCount > 0. See Acting on behalf of a user.

Path Parameters

string
required
The workspace UUID (subtree root).
string
required
The user to offboard.

Body Parameters

string
required
Service keys only — the acting user (must hold remove-member, rank-bounded per node). Required for a key: the sweep’s reach is always that user’s — a key that names nobody is refused with 400 workspace/missing-user-id. Name the owner for a full-subtree sweep.A user token always acts as its own user and must not send it (400 workspace/acting-user-not-allowed). See Acting on behalf of a user.

Response

number
How many membership rows were torn down.
object[]
One { workspaceId, userId } entry per removed membership.
number
How many memberships the target retained because the sweep could not reach them. 0 for an owner or ancestor owner. A service key gets whatever its acting user gets — the credential grants no extra reach here. Equals skipped.length.
object[]
One entry per retained membership — the descendants where the target is still a member after this call.
  • id / name — the workspace, mirroring the ownedWorkspaces shape on the 409. Both are null when you have no standing on that workspace: the sweep tells you a membership survived, but does not disclose the existence or name of a sealed sub-workspace you have no authority over. This is the same sealing fence the roster read applies to include=descendants. Get an owner or ancestor owner of that branch to finish the offboarding.
  • reason — currently always "out-of-reach": your authority does not extend to removing members there.
Only descendants where the target actually still holds a direct membership appear. Unreachable descendants the target was never a member of are never listed — the report is scoped to what actually survived the offboarding, not to the shape of the tree.
skipped covers surviving memberships only. Workspaces the target owns never appear in the 200; they block the sweep with 409 workspace/owns-descendants under the rules above.

Error Responses

The target owns this workspace or one or more of its descendants. Nothing was removed.
  • ownedWorkspaces — one entry per reported owned workspace. Workspaces you have standing on carry id and name and are always reported. Workspaces you have no standing on come back as { id: null, name: null } and are reported only when the target holds a membership this sweep would remove. Named entries come first, in tree order (this workspace, then its descendants level by level); the anonymous ones follow.
  • ownedCount — the number of entries in ownedWorkspaces.
When every entry is named, error reads "The user owns workspaces in this subtree. Transfer or delete them first." Only an owner of a workspace (or an ancestor owner) can transfer it, so anonymous entries mean you need an owner of this workspace to resolve them.
A service key called this route without naming an actingUserId. The sweep’s reach is defined by the acting user’s standing per node, so it must be performed as somebody.
A user token sent actingUserId, even naming its own user. Only a service key names the user it acts as; a user token always acts as its own user.
A field this endpoint reads from the body was sent in the query string. actingUserId and every body field go in the JSON body.
Returned when a service key names an actingUserId that isn’t a user in this project.
Every path id on the workspaces bundle is checked for UUID shape before the route runs, so a malformed one is a plain 400 rather than a 500 from the database.