Skip to main content
Spaces are containers — communities for organizing content. The spaces module covers the space lifecycle and navigation: creating spaces, looking them up by ID, slug, or short ID, updating settings, and traversing parent-child hierarchies. For membership management see Space Members, and for moderation and rules see Space Moderation.

createSpace

Creates a new space.
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" or "members".
string
Who can post content: "anyone", "members", or "admins".
string
Who can find and see the space: "public" (default), "unlisted", or "private". Independent of readingPermission (which governs content). "unlisted" keeps the space out of the directory and search, and out of sub-space lists for non-members, but reachable by id, short id or slug; "private" makes it seen only by its active members (everyone else gets 404), and it can’t be joined: members are added by its moderators and admins. See Space visibility.
boolean
When true, join requests must be manually approved.
boolean
The space’s own NSFW flag. Defaults to false. A space created under an NSFW parent is effectively NSFW regardless of this value. See Space NSFW flagging.
string
Makes this space a child of the specified parent space.
Record<string, any>
Arbitrary metadata attached to the space.
Returns — Promise<Space>

fetchSpace

Fetches a single space, including detailed information, by its ID.
string
required
The Sublay space ID.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
Returns — Promise<SpaceDetailed>

fetchManySpaces

Fetches a paginated, filterable list of public spaces (the space directory). For the spaces the logged-in user belongs to, whatever their visibility, use fetchUserSpaces.
number
The page number to fetch.
number
The number of spaces to return per page.
string
Sort order: "createdAt" (when the space was created), "alphabetical" (by name) or "members" (by active member count). Defaults to "members".
string
Direction, "asc" or "desc", for any sortBy. Left out: A–Z for "alphabetical", otherwise newest / most first.
string
Free-text search term, matched as a case-insensitive substring. Trimmed; a blank value returns 400 space/invalid-query.
"slug" | "name" | "description"
The one field query is matched against. Leave it out to match the slug, the name or the description.
string | "none" | "any"
Which level of the space tree to return. Left out or "none": top-level spaces only (the default). A space id returns that space’s direct sub-spaces the viewer can see that are public or that the viewer is an active member of — the same ones its childSpaces preview shows and its childSpacesCount counts; this is how to page through a space’s sub-spaces (add sortBy: "alphabetical" to order them A–Z by name). An id that matches no space returns an empty page, not a 404. "any" returns spaces at every level.
"include-all" | "exclude" | "only"
Filter by each space’s nsfwEffective (own flag OR any ancestor). "include-all" (default) adds no predicate; "exclude" drops effective-NSFW spaces; "only" returns only them. "only" may return an NSFW child whose safe parent is omitted. See Space NSFW flagging.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
Returns — Promise<PaginatedResponse<Space>>

fetchSpaceBySlug

Fetches a detailed space by its slug.
string
required
The space slug.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
Returns — Promise<SpaceDetailed>

fetchSpaceByShortId

Fetches a detailed space by its short ID.
string
required
The space short ID.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
Returns — Promise<SpaceDetailed>

fetchUserSpaces

Fetches the spaces the logged-in user belongs to, with the user’s membership on each. Every space the user is an active member of is listed, whatever its visibility; a pending, banned or rejected membership of a space the user can’t see (a private space, or one under it) is left out. It can search within them and sort them.
number
The page number to fetch.
number
The number of spaces to return per page.
string
Free-text search term within the user’s spaces, matched as a case-insensitive substring. Trimmed; a blank value returns 400 space/invalid-query.
"slug" | "name" | "description"
The one field query is matched against. Leave it out to match the slug, the name or the description.
string
Sort order: "joinedAt" (when the user joined), "createdAt" (when the space was created), "alphabetical" (by name) or "members" (by active member count). Defaults to "joinedAt".
string
Direction, "asc" or "desc", for any sortBy. Left out: A–Z for "alphabetical", otherwise newest / most first.
string | "none" | "any"
Narrows the list by where each space sits in the tree. "none" returns the user’s memberships in top-level spaces only. A space id returns their memberships in that space’s direct sub-spaces; an id that matches no space returns an empty page, not a 404. "any" or left out: memberships at every level (the default).A membership in a sub-space whose parent the user isn’t a member of is not top-level, so "none" leaves it out.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
string
Filter by role. A single role or a comma-separated list, e.g. "admin,moderator".
string
Membership status to list: "active" (default), "pending", or "banned". Use "pending" to find join requests still awaiting approval.
string
Pass "true" or "false".
Returns — Promise<UserSpacesResponse>

fetchMutualSpaces

Fetches the spaces the logged-in user shares with another user — the spaces both are active members of.
string
required
The other user’s ID. Mutual spaces are computed between this user and the logged-in user.
number
The page number to fetch.
number
The number of spaces to return per page. Max 100.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
Returns — Promise<PaginatedResponse<Space>>

updateSpace

Updates a space’s settings.
string
required
The Sublay space ID.
string
New display name for the space.
string
New URL-friendly identifier.
string
New description of the space.
string
Who can read content: "anyone" or "members".
string
Who can post content: "anyone", "members", or "admins".
string
Updated visibility: "public", "unlisted", or "private". Controls who can find and see the space, independent of readingPermission. See Space visibility.
boolean
Updated NSFW own-flag. Toggling it recomputes this space’s effective NSFW and cascades it top-down to every descendant space (and, live, to their entities). See Space NSFW flagging.
Record<string, any>
Arbitrary metadata attached to the space.
Returns — Promise<Space>

deleteSpace

Deletes a space.
string
required
The Sublay space ID.
Returns — Promise<DeleteSpaceResponse>

checkSlugAvailability

Checks whether a space slug is available.
string
required
The slug to check.
Returns — Promise<{ available: boolean }>

fetchSpaceBreadcrumb

Fetches the path from the top-level space down to and including a space, root first, as the logged-in user may see it. A space the user can’t see is answered 404 space/not-found. Each entry carries hidden: a space above that the user can’t see (a private space they aren’t an active member of, or a space under one) is exactly { hidden: true }, with no other field. Apps can skip those entries, show ”…”, or start after the last hidden one. See Fetch Space Breadcrumb.
string
required
The Sublay space ID.
Returns — Promise<SpaceBreadcrumb>: { breadcrumb, depth }, where each breadcrumb entry is either a visible space (id, shortId, name, slug, avatarFileId, visibility, parentSpaceId, depth, hidden: false) or { hidden: true }.

getSpaceConversation

Gets the chat conversation object associated with a space.
string
required
The Sublay space ID.
Returns — Promise<Conversation>
Space chat messages are sent and read via the chat module.