Skip to main content

Overview

useCreateSpace returns a callable function for creating a new space. The request can include an avatar and a banner image (avatarFile, bannerFile). The creator is automatically added as an admin. A sub-space’s owner (its userId) is the root space’s creator, not whoever created the sub-space: they are its admin, not its owner.

Usage Example

With an avatar:

Parameters

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
Optional URL slug. Must be unique per project. Supports letters, numbers, hyphens, and underscores (Unicode allowed). null is the same as leaving it out.
string | null
Optional description. Up to 1,000 characters. null is the same as leaving it out.
{ file: UploadFileInput; options: UploadImageOptions }
Optional avatar image to upload, up to 50 MB. file is a File or Blob, or a React Native file { uri, name, type? }. options controls how the image is processed and must include mode (see Upload Image). With an image, the request is sent as multipart/form-data.
{ file: UploadFileInput; options: UploadImageOptions }
Optional banner image to upload; same shape as avatarFile.
"anyone" | "members"
Who can read content. Defaults to "anyone".
"anyone" | "members" | "team"
Who can post entities: "anyone", "members" (active members), or "team" (the space’s active admins and moderators). Defaults to "members".
"public" | "unlisted" | "private"
Who can find and see the space. Defaults to "public". 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
The space’s own NSFW flag. Defaults to false. If the space is created under an NSFW parent, its effective NSFW status is true regardless of this value (a live rollup — see Space NSFW flagging). Sublay labels and filters NSFW content; it does not blur or age-gate it.
boolean
Whether new members must be approved. Defaults to true.
Record<string, any>
Optional custom metadata. Up to 1 MB.
string | null
Optional UUID of a parent space. The creator must be an admin of the parent space. null or left out: a top-level space.
With avatarFile or bannerFile, the request is multipart/form-data, which can’t carry null, so null fields are left out of it (the same result as on a JSON request).

Returns

Returns the created Space object plus memberPermissions: what the creator may do in the new space (see SpaceMemberPermissions).
When creating a child space, all admins and moderators of the parent space are automatically added to the new child space with their same roles.