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 and rules see Space Moderation.

createSpace

Creates a new space.
string
required
The user the service key acts as: the user creating the space, who becomes its admin (for a sub-space, its owner is the root space’s creator, not this user), held to their own permissions. A space always has a creator: leaving it out returns 400 space/missing-user-id.
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" (default) or "members".
string
Who can post content: "anyone", "members" (default), 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. Defaults to false.
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 user the space is created for (actingUserId) 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.
object
Arbitrary metadata attached to the space.
{ file: Uint8Array | Blob; filename?: string; mimeType?: string; options: ImageOptions }
An avatar image to upload, up to 50 MB. Raw bytes carry no type, so pass mimeType with a Uint8Array (image/jpeg, image/png or image/webp; without it the file goes as application/octet-stream and is refused with 400 space/unsupported-file-type); a Blob keeps its own type. options says how to process the image and must include mode (see Upload Image). With an image, the request is sent as multipart/form-data.
{ file: Uint8Array | Blob; filename?: string; mimeType?: string; 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 space by its Sublay ID, including member counts and permission details.
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.
string
The user to read as: exactly what their own access token would get (their role, memberPermissions and membership). Omit it for the anonymous view.
Returns — Promise<SpaceDetailed>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); without actingUserId the service key gets the anonymous view, which describes a viewer, not what your backend may write. See How permissions are calculated.

fetchManySpaces

Fetches a paginated list of public spaces (the space directory), with optional text search. For the spaces a user belongs to, whatever their visibility, use fetchMySpaces.
number
Page number (1-indexed). 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, 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.
string
The user to list as: exactly what their own access token would get (their membership on each space). Omit it for the anonymous view.
Returns — Promise<PaginatedResponse<Space>>

fetchSpaceBySlug

Fetches a space by its unique slug.
string
required
The space’s URL slug.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
string
The user to read as: exactly what their own access token would get (their role, memberPermissions and membership). Omit it for the anonymous view.
Returns — Promise<SpaceDetailed>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); without actingUserId the service key gets the anonymous view, which describes a viewer, not what your backend may write. See How permissions are calculated.

fetchSpaceByShortId

Fetches a space by its short, human-readable ID (used in share URLs).
string
required
The space’s short ID.
SpaceIncludeParam
A single value or an array. The only value is "files", which populates the avatar and banner file objects.
string
The user to read as: exactly what their own access token would get (their role, memberPermissions and membership). Omit it for the anonymous view.
Returns — Promise<SpaceDetailed>. Its memberPermissions is always present, also for a user with no membership (isMember: false, status: null); without actingUserId the service key gets the anonymous view, which describes a viewer, not what your backend may write. See How permissions are calculated.

fetchMySpaces

Fetches the spaces the user named by actingUserId is a member of (GET /spaces/mine, acting as that user), with their 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.
string
required
The user the service key acts as, whose spaces to list.
number
Page number (1-indexed), 1 or more. Defaults to 1.
number
Results 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
Filter by the user’s role in the space. A single role or 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 | "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.
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 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
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 settings on an existing space.
string
required
The Sublay space ID to update.
string
required
The user the request acts as: they must be an admin of the space, and the action is recorded as theirs.
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
Updated reading permission: "anyone" or "members".
string
Updated posting permission: "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.
object
Replaces the space’s metadata.
{ file: Uint8Array | Blob; filename?: string; mimeType?: string; options: ImageOptions }
A new avatar image, replacing the current one (up to 50 MB). Raw bytes carry no type, so pass mimeType with a Uint8Array (image/jpeg, image/png or image/webp; without it the file goes as application/octet-stream and is refused with 400 space/unsupported-file-type); a Blob keeps its own type. options says how to process the image and must include mode (see Upload Image). 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: Uint8Array | Blob; filename?: string; mimeType?: string; 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 acting user may do in it after the update (no parentSpace or childSpaces).

deleteSpace

Permanently deletes a space and all its content. The reputation users earned in the space and its sub-spaces is removed from their totals (see Reputation).
string
required
The Sublay space ID to delete.
string
required
The user the request acts as, exactly as their own token would: only the space’s owner may delete it (its userId: the creator of a top-level space, the root space’s creator for a sub-space), and not while banned from the space or from a space above it (403 space/owner-required, 403 space/banned).
Returns — Promise<void>. It resolves with no value once the space is deleted.

checkSlugAvailability

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

fetchSpaceBreadcrumb

Returns the path from the top-level space down to and including the specified space, root first, as the viewer may see it. Useful for rendering breadcrumb navigation. A space the viewer can’t see is answered 404 space/not-found. Each entry carries hidden: a space above that the viewer 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 to get the breadcrumb for.
string
Read as this user: exactly what their own access token would get. Omit it for the anonymous view.
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 }.