Skip to main content
The 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.
Naming an actingUserId means being that user. It is not a hint or an audit tag — it binds. Every check the named user would face runs: the capability gate, the owner-only gate, the rank guard, no-escalation, and the roster/standing fencing. If that user would be refused, so are you. There is no mode in which a key acts on a workspace with authority of its own.So an unrestricted backend action is performed as the workspace owner: the owner resolves the full capability vocabulary and apex rank, and the resulting webhooks carry that user id. Treat that id as a claim, not proof — a key may name any user in the project (an id that isn’t one gets 404 workspace/user-not-found). Two consequences bite first-time integrators — acceptWorkspaceInvite requires the invite to be actually addressed to the named user and that user’s email to be verified, and a rank tier cannot grow itself (see createWorkspaceInvite). Full rule: Acting on behalf of a user.
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.
Absent, not falsy — and undeclared fields are refused, not ignored. actingUserId: "" or null is a 400 that names the field, so actingUserId: user?.id ?? "" fails with an error about the actor rather than a missing-user error.Every workspaces endpoint also declares its fields exactly, and refuses any top-level field it does not declare, for every caller — in the body of a write, with { "error": "Unrecognized key: \"onBehalfOf\"", "code": "workspace/invalid-body", "param": "onBehalfOf" } (plural Unrecognized keys: "a", "b" for two or more), and in the query string of a read or delete, with workspace/invalid-query. This SDK sends each call’s fields where the server reads them: the query string on reads and deletes (deleteWorkspace, leaveWorkspace and removeWorkspaceMember included), the JSON body on writes. So onBehalfOf, impersonate and acting_user_id all fail at the wire rather than being dropped silently. A userId anywhere in a body or query is refused with a message of its own — the sole exception is the invitee in createWorkspaceInvite’s body, and even there a query ?userId= is refused like everywhere else. A non-UUID id in a path is a 400 workspace/invalid-params rather than a 500. Full list with the reasoning: Shapes the server rejects.One of those rules cannot bite you through this SDK: a body whose content-type no parser reads is refused when a key names nobody, and this SDK serializes every body it sends as application/json. It is a hazard for hand-rolled fetch() calls, not for sublay.workspaces.*.
Pass only the documented fields — the props object is sent whole. createWorkspace and its siblings hand your object straight to the request body, so a convenience spread carries whatever else it holds into the request, and the endpoint refuses it:
Your own data belongs in metadata, which is opaque to Sublay and accepts any JSON. Strictness governs top-level keys only, so nothing inside metadata is inspected.
Read the concepts first: capabilities vs permissions, rank, reach & ownership, and the identity-matched, no-token invite model.

Workspace lifecycle

createWorkspace

Root creation requires the acting user to have a verified email. Child creation requires the create-sub-workspace capability on the parent; the creator becomes the child’s owner.
A service key does NOT bypass the verified-email gate. The actingUserId you act as must itself be verified, or the call returns 403 workspace/email-not-verified. This matches acceptWorkspaceInvite and transferWorkspaceOwnership — all three doors into ownership check it, so every workspace owner has a confirmed email. A key lets you act as a user; it does not make that user verified.
string
required
The user the workspace is created as (becomes the owner).
string
required
Display name (1–100 characters).
object
Opaque developer data.
string
Parent for child creation; absent/null → root.

fetchWorkspace

string
required
The workspace UUID.
WorkspaceIncludeParam
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.
string
required
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 with relation: "direct" only the ones they own or are a member of. Each row carries reasons, why that user can open it.
string
required
The user whose workspaces to list, and whose reasons each row carries.
"reachable" | "direct"
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.
string | "none" | "any"
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).
"desc" | "asc"
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.
number
number
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.
WorkspaceIncludeParam
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’s reasons is the acting user’s standing on it.
string
required
The user to act as, whose workspaces are compared with userId’s.
string
required
The other user, sent in the path. An ID that matches no user returns an empty page.
"reachable" | "direct"
"reachable" or left out (the default): workspaces each user can open. "direct": workspaces each user owns or has a member row on.
"desc" | "asc"
Order by creation time: "desc" (the default) or "asc".
number
number
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.
WorkspaceIncludeParam
The only value is "memberCount".

updateWorkspace

Edits name/metadata (gated by edit-workspace or owner). Does not flip the inherit flag.
string
required
string
required
The user to act as — must hold edit-workspace on this workspace, or own it.
string
object

updateWorkspaceInheritFlag

Owner-only in both directions; subject to the enforced-default lock.
string
required
string
required
The user to act as — must own this workspace or an ancestor.
boolean
required

deleteWorkspace

Owner-only; cascades the subtree and fires workspace.deleted per deleted workspace — and no workspace.member.removed events for the memberships it tears down (see Webhooks).
string
required
string
required
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 the title 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.
string
required
string
required
The user to act as — must own this workspace or an ancestor.
string
required
The new owner (any verified user).
string
"demote" or "remove". Defaults to "remove" when omitted.
number
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.
WorkspaceCapability[]
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.
string
required
WorkspaceMemberIncludeParam
A single value or an array of "ancestorOwners", "reachHolders", "descendants".
boolean
string
required
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.
string
required
string
required
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.
Returns WorkspaceMemberStanding.

fetchWorkspaceMemberStanding

Another user’s standing. A targetUserId equal to actingUserId is refused with 400 workspace/own-member-id: read the acting user’s own with fetchMyWorkspaceMembership.
string
required
string
required
The user whose standing to read.
string
required
The user to act as. Sent as a query param. Roster visibility and the authority-field fence both evaluate against them.
Returns 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

Powerful fields require 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.
string
required
string
required
The member being edited (path).
string
required
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.
WorkspaceCapability[]
Values from the closed capability vocabulary; any other value is a 400.
string[]
number
Absolute. Mutually exclusive with relativeRank; omit both to leave rank unchanged.
number
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.
string
object

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.
string
required
string
required
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.
string | null
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.
object
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).
Returns 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

Requires remove-member (rank-bounded); sole-owner protected. A targetUserId equal to actingUserId is refused with 400 workspace/own-member-id: to leave, use leaveWorkspace.
string
required
string
required
The member to remove.
string
required
The acting user. Sent as a query param.

leaveWorkspace

Removes the given user’s own membership on this node only (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.
string
required
string
required
The user leaving. Sent as a query param.

removeWorkspaceMemberFromSubtree

A 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.
string
required
string
required
The user to offboard.
string
required
The acting user.

Invitations

createWorkspaceInvite

Requires the 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.
The project must have workspaces.inviteAcceptUrl configured, or this call fails with 409 workspace/missing-invite-accept-url and persists nothing. It has no default, and a service key does not exempt you. Applies even when the invitee already has an account. See Project settings.
string
required
string
One of email/userId/username.
string
Invite target user id.
string
Invite target username.
WorkspaceCapability[]
Values from the closed capability vocabulary; any other value is a 400.
string[]
number
Absolute. Not required — mutually exclusive with relativeRank, and omitting both applies the relativeRank: 1 default.
number
default:"1"
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.
string
string
required
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.
Returns a 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

The workspace’s outbox — the live pending invites it has issued. Requires invite (or owner). Not to be confused with fetchMyWorkspaceInvites, which is one user’s inbox of invites addressed to them across every workspace.
string
required
string
required
The user to act as. Sent as a query param. invite (or ownership) is required of them.

revokeWorkspaceInvite

string
required
string
required
string
required
The user to act as. invite (or ownership) is required of them.

resendWorkspaceInvite

Refreshes a lapsed pending invite (14-day expiry) and resends the email. Terminal invites → 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.
string
required
string
required
string
required
The user to act as. invite (or ownership) is required of them.

acceptWorkspaceInvite

Identity-matched + verified-email. Returns the accepting user’s standing, a 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.
string
required
string
required
The accepting user (must be the target and verified).

declineWorkspaceInvite

Identity-matched + verified-email — the same gate as accept, so an unverified squatter on someone else’s address cannot burn their invite. A service key does not bypass it: the actingUserId you act as must itself be verified, or the call returns 403 workspace/email-not-verified.
string
required
string
required
The declining user (must be the target and verified).

fetchMyWorkspaceInvites

The user’s inbox — their live pending invites addressed to them across every workspace (matched by userId). The per-workspace outbox counterpart is fetchWorkspaceInvites.
string
required
The user whose inbox to read. Sent as a query param.

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().
string
required
string
required
The acting user whose resolved standing to read.
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.