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: 3–100 characters after trimming. Every space has a name; without one the server returns 400 space/invalid-body.
string | null
URL-friendly identifier. Must be unique within the project. Left out or null, the space has no slug.
string | null
Short description of the space. Left out or null, the space has no description.
string
Who can read content: "anyone" or "members".
string
Who can post content: "anyone", "members", or "team" (the space’s active admins and moderators).
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 | null
Makes this space a child of the specified parent space. The signed-in user must be an active admin of the parent space, or the request is refused with 403 space/parent-admin-required. Left out or null, the space is top-level.
Record<string, any>
Arbitrary metadata attached to the space.
{ file: Blob | File; options: ImageOptions }
An avatar image to upload, up to 50 MB. options says how to process it and must include mode (see Upload Image). With an image, the request is sent as multipart/form-data.
{ file: Blob | File; options: ImageOptions }
A banner image to upload; same shape as avatarFile.
Returns — Promise<SpaceWithPermissions>: the created space plus memberPermissions, what the creator may do in it.

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>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); a signed-out user gets the anonymous view. See How permissions are calculated.

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 fetchMySpaces.
number
The page number to fetch.
number
The number of spaces to return per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 space/invalid-query, never lowered to 100.
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>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); a signed-out user gets the anonymous view. See How permissions are calculated.

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>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); a signed-out user gets the anonymous view. See How permissions are calculated.

fetchMySpaces

Fetches the spaces the logged-in user belongs to (GET /spaces/mine), 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 (1-indexed), 1 or more. Defaults to 1.
number
The number of spaces to return per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 space/invalid-query (param: "limit"), never lowered to 100. See Pagination.
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.
Returns — Promise<MySpacesResponse> The list is always paged. To load every space the user is in, fetch page after page until pagination.hasMore is false; add role: "admin,moderator" to list only the spaces they moderate:

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: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 space/invalid-query, never lowered to 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 (3–100 characters after trimming). Leave it out to keep the current name; a name can’t be cleared.
string | null
New slug. Must be unique. null clears it.
string | null
New description. null clears it.
string
Who can read content: "anyone" or "members".
string
Who can post content: "anyone", "members", or "team" (the space’s active admins and moderators).
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.
boolean
Whether joining needs approval. Applies to joins from now on.
Record<string, any>
Arbitrary metadata attached to the space.
{ file: Blob | File; options: ImageOptions }
A new avatar image, replacing the current one (up to 50 MB). options must include mode. With an image, the request is sent as multipart/form-data. A field set to null can’t travel with an image: the call throws before sending anything, so clear it in a separate call without one.
{ file: Blob | File; options: ImageOptions }
A new banner image, replacing the current one; same shape as avatarFile.
string[]
Files to remove: the space’s avatarFileId and/or bannerFileId, nothing else. Removing one clears that image. Works alone or with uploads. Any other id throws a 400 (space/invalid-remove-file-ids, with invalidIds).
Returns — Promise<SpaceWithPermissions>: the updated space plus memberPermissions, what the user may do in it after the update (no parentSpace or childSpaces).

deleteSpace

Deletes a space. Only the space’s owner can delete it: its userId, which is the creator of a top-level space and the root space’s creator for a sub-space. The reputation users earned in the space and its sub-spaces is removed from their totals (see Reputation).
string
required
The Sublay space ID.
Returns — Promise<void>. It resolves with no value once the space is deleted.

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.