Skip to main content
The spaces module covers core space lifecycle management: creating spaces, fetching them by various identifiers, updating settings, navigating parent-child hierarchies, and checking slug availability. For membership management see Space Members, and for moderation, rules, and digest configuration see Space Moderation.

createSpace

Creates a new space.
string
required
The Sublay user ID of the space creator, who becomes the initial admin.
string
required
Display name for the space.
string
URL-friendly identifier. Must be unique within the project. Generated from name if omitted.
string
Short description of the space.
string
Who can read content: "anyone" (default) or "members".
string
Who can post content: "anyone", "members" (default), or "admins".
boolean
When true, join requests must be manually approved. Defaults to false.
string
Makes this space a child of the specified parent space.
object
Arbitrary metadata attached to the space.
ReturnsPromise<Space>

fetchSpace

Fetches a space by its Sublay ID, including member counts and permission details.
string
required
The Sublay space ID.
ReturnsPromise<SpaceDetailed>

fetchManySpaces

Fetches a paginated list of top-level spaces, with optional text search.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Sort order: "alphabetical", "newest", or "members".
string
Filter spaces whose name matches the query.
string
Filter spaces whose slug matches the query.
string
Filter spaces whose description matches the query.
string
Filter spaces matching the query across name, slug, or description.
"true"
When "true", returns only spaces the requesting context is a member of.
string | "null"
Filter to children of a specific space, or pass "null" for top-level spaces only.
string
Comma-separated list of associations to populate.
ReturnsPromise<PaginatedResponse<Space>>

fetchSpaceBySlug

Fetches a space by its unique slug.
string
required
The space’s URL slug.
ReturnsPromise<SpaceDetailed>

fetchSpaceByShortId

Fetches a space by its short, human-readable ID (used in share URLs).
string
required
The space’s short ID.
ReturnsPromise<SpaceDetailed>

fetchUserSpaces

Fetches the spaces a specific user is a member of.
string
required
The Sublay user ID.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Sort order: "alphabetical", "newest", or "members".
string
Filter by the user’s role in the space. A single role or comma-separated list, e.g. "admin,moderator".
"true" | "false"
When "true", returns the full set of spaces rather than only the paginated page.
string
Comma-separated list of associations to populate.
ReturnsPromise<UserSpacesResponse>

fetchMutualSpaces

Fetches the spaces shared between two users — the spaces both are active members of.
string
required
The other user’s Sublay ID. Mutual spaces are computed between this user and actingUserId.
string
required
The user to act as. Because the SDK authenticates with a service key, you must name the acting user explicitly.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Max 100. Defaults to 20.
string
Comma-separated list of associations to populate (e.g. "files").
ReturnsPromise<PaginatedResponse<Space>>

updateSpace

Updates settings on an existing space.
string
required
The Sublay space ID to update.
string
New display name.
string
New slug. Must be unique.
string
New description.
string
Updated reading permission: "anyone" or "members".
string
Updated posting permission: "anyone", "members", or "admins".
object
Updated metadata. Merged with existing values.
ReturnsPromise<Space>

deleteSpace

Permanently deletes a space and all its content.
string
required
The Sublay space ID to delete.
ReturnsPromise<DeleteSpaceResponse>

checkSlugAvailability

Checks whether a slug is available for use.
string
required
The slug to check.
ReturnsPromise<{ available: boolean }>

fetchChildSpaces

Fetches the direct child spaces of a given parent space.
string
required
The parent Sublay space ID.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Sort order: "alphabetical", "newest", or "members".
string
Comma-separated list of associations to populate.
ReturnsPromise<PaginatedResponse<Space>>

fetchSpaceBreadcrumb

Returns the full ancestor chain from the root down to the specified space. Useful for rendering breadcrumb navigation.
string
required
The Sublay space ID to get the breadcrumb for.
ReturnsPromise<SpaceBreadcrumb>