Skip to main content

Overview

useUpdateSpace returns a callable function for updating a space. Only space admins can update a space. Supports replacing the avatar and banner images (avatarFile, bannerFile) and removing them (removeFileIds).
When using SpaceProvider, prefer calling updateSpace from useSpace — it handles state updates automatically.

Usage Example

Parameters

string
required
UUID of the space to update.
The changes go next to spaceId, all optional, not inside an update object (an update key throws a SublayError before anything is sent).
string
New display name (3–100 characters after trimming). Leave it out to keep the current name; a name can’t be removed.
string | null
New URL slug. Pass null to remove it.
string | null
New description. Pass null to remove it.
"anyone" | "members"
Updated reading permission.
"anyone" | "members" | "team"
Updated posting permission: "anyone", "members" (active members), or "team" (the space’s active admins and moderators).
"public" | "unlisted" | "private"
Updated visibility: who can find and see the space (and the spaces under it). 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) in the same transaction. See Space NSFW flagging.
boolean
Updated join approval requirement.
Record<string, any>
Updated metadata.
{ file: UploadFileInput; options: UploadImageOptions }
New avatar image, replacing the current one. file is a File or Blob, or a React Native file { uri, name, type? }; options must include mode (see Upload Image). With an image, the request is sent as multipart/form-data.
{ file: UploadFileInput; options: UploadImageOptions }
New banner image, replacing the current one; same shape as avatarFile.
string[]
Files to remove: the space’s avatarFileId and/or bannerFileId. Removing one clears that image. Any other id refuses the whole update (400 space/invalid-remove-file-ids).
With avatarFile or bannerFile, the request is multipart/form-data, which can’t carry null. A null field next to a file throws before anything is sent (`slug: null` can't be sent with a file); clear the field in a separate call without a file.

Returns

Returns the updated Space object plus memberPermissions: what the user may do in the space after the update (see SpaceMemberPermissions). It carries no parentSpace or childSpaces. Inside a SpaceProvider for the same space, the provider’s space takes the update and the new memberPermissions, keeping its hierarchy.