workspaces module is the developer’s authorization-server SDK for the Workspaces bundle. It exposes the full surface: workspace CRUD, membership management, the invitation lifecycle, and the service-key authority read you use to make your own app-level decisions.
Requires the
workspaces bundle. See Bundles to install it. As on every Node SDK call that acts as a user, the user the action is performed as goes in actingUserId, and every workspace call accepts it. It is required on every call — see the note below. For fetchWorkspaceAuthority, actingUserId is the user whose standing is resolved.This SDK is not required in order to manage workspaces. All 22 endpoints are equally available to a browser or mobile app through the
@sublay/core hooks and @sublay/js, acting as the signed-in user and subject to the same ownership / capability / rank rules. What the node SDK adds is performing an action as some other named user through actingUserId, which only a service key may send.The actor is required on every call.
actingUserId is typed
required on every function in this module. The server refuses a key that
names nobody with 400 workspace/missing-user-id on every workspace route but
one: on Fetch Workspace it
gets the anonymous view, which for a workspace is always a 404.Workspace lifecycle
createWorkspace
create-sub-workspace capability on the parent; the creator becomes the child’s owner.
fetchWorkspace
A single value or an array, sent as a query param. The only value is
"memberCount": it adds the workspace’s direct member count; omit it and the field is absent. The server rejects any other value with 400 workspace/invalid-query.The user to act as. Sent as a query param. Visibility resolves against them, so a key acting as someone with no relation to this workspace gets that user’s
404.fetchManyWorkspaces
Lists a user’s workspaces (paginated): by default every workspace they can open, or withrelation: "direct" only the ones they own or are a member of. Each row carries reasons, why that user can open it.
Which workspaces the list holds.
"reachable" or left out (the default): every workspace the user can open — owned, a member of, under a workspace they own, or reached by a capability held on an ancestor. "direct": only the workspaces they own or have a member row on.Narrows the list by where each workspace sits in the tree, within
relation. "none": top-level workspaces only. A workspace id: the workspaces directly under that workspace; an id that matches no workspace returns an empty page, not a 404. "any" or left out: workspaces at every level (the default).Order by creation time.
"desc" or left out (the default): newest first. "asc": oldest first, which puts every parent before its children — see Building a workspace switcher.Results per page: a whole number from
1 to 100. Defaults to 20. A larger value is rejected with 400 workspace/invalid-query, never lowered to 100.A single value or an array, sent as a query param. The only value is
"memberCount": it adds a memberCount to every row — the workspace’s direct member count, resolved in one grouped query over the returned page rather than one request per row. Omit it and the field is absent from each row.fetchMutualWorkspaces
Lists the workspaces the acting user and another user have in common (paginated). Each row’sreasons is the acting user’s standing on it.
"reachable" or left out (the default): workspaces each user can open. "direct": workspaces each user owns or has a member row on.Results per page: a whole number from
1 to 100. Defaults to 20. A larger value is rejected with 400 workspace/invalid-query, never lowered to 100.updateWorkspace
edit-workspace or owner). Does not flip the inherit flag.
updateWorkspaceInheritFlag
deleteWorkspace
workspace.deleted per deleted workspace — and no workspace.member.removed events for the memberships it tears down (see Webhooks).
The user to act as — must own this workspace or an ancestor. Sent as a query param. This call cascade-deletes the whole subtree, so name the owner deliberately.
transferWorkspaceOwnership
Titles travel with the people: the new owner keeps thetitle and metadata they had as a member, and the previous owner keeps theirs when demoted. A previous owner who is removed loses theirs. See Transfer Ownership.
On demote, the ex-owner’s rank (absolute only). Defaults to one rung below the acting user’s anchor —
0 when the actor is apex (an owner or ancestor owner with no member row here, which is the usual case), or one below their own row when the named actingUserId sits in this workspace’s ladder.Values from the closed capability vocabulary; any other value is a
400.Membership
fetchWorkspaceMembers
Returns the unified roster (WorkspaceRosterResponse), or WorkspaceRosterCountsResponse when countOnly is set.
Each entry’s user is a WorkspaceStandingUser: the full public user record, or { id } alone when the user row no longer exists, so only id is guaranteed.
The roster fences the authority-bearing reason fields (
rank, relativeRank, capabilities, permissions) from callers who cannot manage people on the workspace — per node, so with include=descendants each descendant-member reason is judged against the acting user’s resolved standing on that descendant, and authority over the parent does not unfence a sealed child. The fence evaluates against the actingUserId you pass, so a key acting as a plain member receives the same partial roster that member would. The SDK types mark the four fields optional for that reason.A member reason carries both rank coordinates: absolute rank, and relativeRank — that member’s position as an offset from the caller, meaning the acting user when you name one. descendant-member reasons carry rank only, since their ranks belong to another node’s ladder.A single value or an array of
"ancestorOwners", "reachHolders", "descendants".The user to act as. Sent as a query param. Roster visibility and the authority-field fence both evaluate against them.
fetchMyWorkspaceMembership
The acting user’s own resolved standing on a workspace (GET /workspaces/:workspaceId/members/me): the same WorkspaceMemberStanding record fetchWorkspaceMemberStanding returns for another user. A user’s own access is never fenced, so capabilities, permissions, rank and relativeRank are always present; relativeRank is 0 when they hold a member row on this workspace and null when they don’t (an owner or ancestor owner without one). A user with no relation to the workspace gets 404 workspace/not-found, as for a missing workspace. See Fetch My Membership.
The user whose standing to read: the request acts as them. Sent as a query param. Omitting it is a
400 workspace/missing-user-id.WorkspaceMemberStanding.
fetchWorkspaceMemberStanding
Another user’s standing. AtargetUserId equal to actingUserId is refused with 400 workspace/own-member-id: read the acting user’s own with fetchMyWorkspaceMembership.
The user to act as. Sent as a query param. Roster visibility and the authority-field fence both evaluate against them.
WorkspaceMemberStanding. On its user field only id is guaranteed (WorkspaceStandingUser): the server returns the full user record when the user row still exists and falls back to { id } alone when it does not — a deleted user with a lingering membership row is a reachable case. Read the rest defensively (standing.user.username ?? "Deleted user").
reasons is an array of structured { type, viaWorkspaceId? } entries — the same shape a roster entry’s reasons carries — so you learn not just the kind of standing but which ancestor grants it. capabilities / permissions / rank / relativeRank are typed optional because the server omits them for callers who cannot manage people (relativeRank is fenced with rank — it is rank minus an anchor the caller already knows). The fence evaluates against the actingUserId you pass, who may well not see them.
updateWorkspaceMember
edit-member-access + rank rules + no-escalation; cosmetic fields require edit-member-profile. A targetUserId equal to actingUserId is refused with 400 workspace/own-member-id: a user edits their own title with updateMyWorkspaceMembership. The workspace’s owner is never a target, whoever the key acts as: naming them gets 404 workspace/not-found, and their title and metadata are set only by a key acting as the owner, with updateMyWorkspaceMembership.
Rank moves in either coordinate — rank (absolute) or relativeRank (an offset from actingUserId), never both. Omitting both means rank unchanged. See choosing a rank.
The acting user (body). Omitting it is a
400 workspace/missing-user-id. Every gate — both capability tiers, the rank guard, the assign rule, no-escalation — runs against this user. Act as the owner for an unrestricted edit.Values from the closed capability vocabulary; any other value is a
400.An offset from the acting user —
1 = one rung below them. Must be >= 1. Anchored on their member row on this workspace if they hold one, apex otherwise, so a key acting as the owner resolves relativeRank: 1 to rank 0. Resolved to an absolute rank at write time and frozen. No default.updateMyWorkspaceMembership
The acting user edits their own profile on a workspace (PATCH /workspaces/:workspaceId/members/me). Needs no capability. A member edits their title only; a member’s other fields are edited by a member with the capability, through updateWorkspaceMember. The workspace’s owner (a key acting as the owner) edits their title and metadata here, and only here: they are profile only and change nothing about the owner’s authority. An acting user who can see the workspace but is not its owner and holds no member row on it gets 403 workspace/not-member; one with no relation to it gets 404 workspace/not-found, as for a missing workspace. See Update My Membership.
The user whose own profile to edit: the request acts as them. Sent in the body. Omitting it is a
400 workspace/missing-user-id.Trimmed, up to 100 characters.
null clears it. Required for a member; the owner sends title, metadata or both. Leaving it out keeps the current title.The owner only. Replaces the owner’s metadata (up to 1 MB). Anyone else who sends it gets
400 workspace/unsupported-param, even with no member row here (refused before the row is looked up).WorkspaceMember | WorkspaceOwnerProfile: for a member, the same WorkspaceMember record updateWorkspaceMember returns; for the owner, a WorkspaceOwnerProfile, the same fields holding the profile only, with rank: null and empty capabilities / permissions, since the owner’s access comes from ownership.
removeWorkspaceMember
remove-member (rank-bounded); sole-owner protected. A targetUserId equal to actingUserId is refused with 400 workspace/own-member-id: to leave, use leaveWorkspace.
leaveWorkspace
DELETE /workspaces/:workspaceId/members/me). An owner cannot leave (409 workspace/sole-owner). A user who only reaches in, with no direct membership here, gets 403 workspace/not-member; one who can’t see the workspace gets 404 workspace/not-found, as for a missing one.
removeWorkspaceMemberFromSubtree
targetUserId equal to actingUserId is refused with 400 workspace/own-member-id. If the target owns this workspace or a descendant, it is refused with 409 workspace/owns-descendants and nothing is removed. Owned workspaces the acting user has standing on always count and are named in ownedWorkspaces. Ones the acting user has no standing on (for example sealed sub-workspaces) count only when the target holds a membership this call would remove, and are listed as { id: null, name: null } after the named ones. ownedCount is the number of entries. An owner of each workspace (or an ancestor owner) must transfer or delete it before a retry. See Remove From Subtree.
skippedCount reflects the acting user, not the key. The sweep is partial for a non-owner actor, and actingUserId is required on this call — a key always names someone, and is bound by their reach and their per-node rank. Name a non-owner admin and you can get a partial sweep, exactly as that admin would; name the owner for the god-path that clears every descendant. Always assert on skippedCount rather than assuming removedCount means the user is fully offboarded.Invitations
createWorkspaceInvite
invite capability. Here userId/username (if used) address the invite target; the inviter is actingUserId, which is required and recorded as the invitation’s invitedById. Email matching against existing accounts is case-insensitive.
The invited grant is floored by the inviter’s own standing: no-escalation on capabilities/permissions, and a rank strictly below the inviter’s own. Both floors are skipped for an owner.
The invited rank is named in either coordinate — rank (absolute) or relativeRank (an offset from the inviter) — and they are mutually exclusive. Supplying neither applies relativeRank: 1, one rung below the inviter, which is well defined for every inviter (one with no member row here anchors at apex, so the default lands on rank 0) and by construction never trips the rank floor.
A tier cannot grow itself. Acting as a rank-5 manager with a direct member row you can invite rank 6, 7, 8… but never another rank 5, and no ranked member clears the floor for rank 0. The floor binds only an inviter with a direct member row on the workspace — an owner or ancestor owner and a reach-holder with no direct row skip it entirely. If your product has a server-driven “add a manager” action, act as the owner for it. See Acting on behalf of a user.
Values from the closed capability vocabulary; any other value is a
400.Absolute. Not required — mutually exclusive with
relativeRank, and omitting both applies the relativeRank: 1 default.An offset from the inviter —
1 = one rung below them. Must be >= 1. Anchored on the inviter’s member row on this workspace if they hold one, apex otherwise. A snapshot: resolved to an absolute rank here and frozen, so a later promotion or demotion of the inviter does not move the pending invite. Note the collision caveat, which is at its sharpest here: an inviter with no member row on this workspace — typically the owner — anchors at apex, so the default mints rank 0 — the most senior rung — for every invitee. A backend invite flow that wants people at the bottom of the ladder must name an absolute rank, or name an actingUserId who actually sits in the ladder. For an in-ladder inviter the default instead puts a whole cohort on one rung, where equals cannot manage each other. See choosing a rank.The inviter to act as. The
invite capability, the no-escalation and rank floors run against their standing, and the invitation’s invitedById records them. Distinct from userId, which is the invitee.WorkspaceInvitation: the new invitation, or the target’s live pending invitation updated in place (same id, new expiry). It resolves with the same record either way, so inviting someone again is safe. A target who is already a member or owns the workspace → 409 workspace/already-member.
fetchWorkspaceInvites
invite (or owner). Not to be confused with fetchMyWorkspaceInvites, which is one user’s inbox of invites addressed to them across every workspace.
revokeWorkspaceInvite
resendWorkspaceInvite
409. Returns the refreshed WorkspaceInvitation, carrying the new expiresAt. Like createWorkspaceInvite, it requires workspaces.inviteAcceptUrl on the project → otherwise 409 workspace/missing-invite-accept-url with expiresAt untouched.
acceptWorkspaceInvite
WorkspaceMemberStanding — the same record fetchMyWorkspaceMembership returns, every field present. It resolves with the same record whether the accept just made them a member or they already were one (or own the workspace), so accepting again an invite they already accepted, while still a member, is safe. An invite declined, revoked, accepted by another user, accepted before the user left the workspace, or expired → 409 workspace/not-pending.
declineWorkspaceInvite
actingUserId you act as must itself be verified, or the call returns 403 workspace/email-not-verified.
fetchMyWorkspaceInvites
userId). The per-workspace outbox counterpart is fetchWorkspaceInvites.
Authority-as-a-service
fetchWorkspaceAuthority
The service-key authority read — the crux of the server-side surface. Resolve any user’s standing on a workspace, then run your own permission check with a one-line.includes().
reasons entries carry viaWorkspaceId on ancestor-owner / reach-holder, naming the ancestor responsible — so when a user has authority you did not expect, you can tell exactly which node to go fix. capabilities is the fully-resolved set, and view is implied by every other capability: any user with standing carries it, and a user with no relation at all gets 404 workspace/not-found instead of a record. There is no relativeRank on this read — it is an offset from the caller, and here the caller is the subject, so rank is the coordinate it reports.
Sublay never consumes your opaque permissions — there is deliberately no ?permission= check or can() helper.
