> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Space

> The shape of a Space object returned by the Spaces API and SDK

A Space is a community container — a named area where users can post entities, discuss in threads, and interact under configurable membership and permission rules. Spaces support hierarchical nesting, customizable read/post permissions, and avatar and banner images.

The API returns three space shapes depending on context:

* **`Space`** — the standard shape, returned when fetching a list of spaces.
* **`SpaceDetailed`** — returned when fetching a single space by ID, shortId, or slug. A superset of `Space` with added permission and hierarchy context.
* **`SpacePreview`** — a minimal snapshot, never returned as a standalone response. Only appears embedded inside `SpaceDetailed` as the shape of `parentSpace` and each item in `childSpaces[]`.

## Space

| Property | Type | Description |
| - | - | - |
| `id` | `string` | Unique space identifier (UUID). |
| `shortId` | `string` | Short human-readable ID for the space (URL-safe, generated automatically). |
| `projectId` | `string` | The project this space belongs to. |
| `slug` | `string \| null` | Optional URL-friendly slug. Unique per project when set. |
| `name` | `string` | Display name of the space (3–100 characters). |
| `description` | `string \| null` | Optional description (up to 1,000 characters). |
| `userId` | `string` | ID of the space creator/owner. |
| `avatarFileId` | `string \| null` | ID of the space's avatar image file. |
| `avatarFile` | `File \| undefined` | Populated avatar file object. Only present when `include: "files"` is requested. |
| `bannerFileId` | `string \| null` | ID of the space's banner image file. |
| `bannerFile` | `File \| undefined` | Populated banner file object. Only present when `include: "files"` is requested. |
| `readingPermission` | `"anyone" \| "members"` | Who may read content in the space, for your app to enforce. The v7 API stores and returns it and reports it in `memberPermissions.canRead`, but doesn't hide the entities, comments or other content inside the space; it applies it only to the [members](https://docs.sublay.io/v7/api-reference/spaces/membership/list-members.md) and [team](https://docs.sublay.io/v7/api-reference/spaces/membership/list-team.md) lists. See [Content inside a space](#content-inside-a-space). |
| `postingPermission` | `"anyone" \| "members" \| "admins"` | Who may post entities in the space, for your app to enforce: anyone, its active members (`"members"`), or its active admins (`"admins"`). The v7 API stores and returns it and reports it in `memberPermissions.canPost`, but doesn't refuse an entity or comment that doesn't match it. See [Content inside a space](#content-inside-a-space). |
| `visibility` | `"public" \| "unlisted" \| "private"` | Who can find and see the space — independent of `readingPermission`, which says who may read the content. `public` (the default) is listed; `unlisted` isn't listed for non-members but is reachable by direct link/slug; `private` hides the space from everyone except its active members (the space's own routes answer `404`, it's never listed, it can't be joined), and hides the spaces under it too. The content inside stays readable in v7. See [Visibility](#visibility) below. |
| `nsfw` | `boolean` | The space's **own** NSFW flag. `false` by default. Set by space admins on [create](https://docs.sublay.io/v7/hooks/spaces/use-create-space.md)/[update](https://docs.sublay.io/v7/hooks/spaces/use-update-space.md) or by a project admin from the dashboard. See [NSFW flagging](#nsfw-flagging). |
| `nsfwEffective` | `boolean` | **Denormalized, read-only.** `true` when this space's own `nsfw` is `true` **or** any ancestor space is NSFW. Maintained top-down on write and cascaded to descendants. This is the value the space `nsfwFilter` keys off, and it feeds each entity's live `nsfwEffective`. See [NSFW flagging](#nsfw-flagging). |
| `requireJoinApproval` | `boolean` | Whether joining requires moderator/admin approval. When `true`, new joins enter `pending` status. |
| `parentSpaceId` | `string \| null` | ID of the parent space, if this is a sub-space. |
| `depth` | `number` | Nesting depth (0 for root spaces, incremented for each sub-level). Maximum depth is 10. |
| `metadata` | `Record<string, any>` | Arbitrary key-value data attached to the space. Up to 1 MB. |
| `isMember` | `boolean \| undefined` | Whether the authenticated user is a member of this space. Only present when the user is signed in. |
| `membersCount` | `number` | Computed count of active members. |
| `childSpacesCount` | `number` | Computed count of the direct child spaces the caller can list under this space: ones they can see that are `public` or that they're an active member of. Matches `childSpaces` and [Fetch Space Children](https://docs.sublay.io/v7/api-reference/spaces/fetch-children.md). |
| `createdAt` | `Date` | Timestamp when the space was created. |
| `updatedAt` | `Date` | Timestamp when the space was last updated. |

## SpaceDetailed

Returned when fetching a single space by ID, shortId, or slug. Includes all `Space` fields plus the following:

| Property | Type | Description |
| - | - | - |
| `memberPermissions` | `SpaceMemberPermissions \| null` | The authenticated user's resolved permissions in this space. `null` if the user is not a member. |
| `parentSpace` | `SpacePreview \| null` | Preview of the parent space. `null` for root-level spaces, and when the caller can't see the parent (`parentSpaceId` still holds its id). |
| `childSpaces` | `SpacePreview[]` | Preview of up to 10 immediate child spaces: the ones the caller can see that are `public` or that they're an active member of. |

## SpacePreview

A minimal space shape used only as an embedded reference — never returned directly by any endpoint. Appears as `SpaceDetailed.parentSpace` (the space one level up) and inside `SpaceDetailed.childSpaces[]` (spaces one level down).

| Property | Type | Description |
| - | - | - |
| `id` | `string` | Space UUID. |
| `shortId` | `string` | Short identifier. |
| `name` | `string` | Display name. |
| `slug` | `string \| null` | URL slug. |
| `avatarFileId` | `string \| null` | Avatar file ID. |
| `readingPermission` | `"anyone" \| "members" \| undefined` | Reading permission level. |
| `visibility` | `"public" \| "unlisted" \| "private" \| undefined` | Listing/discoverability level. |
| `parentSpaceId` | `string \| null \| undefined` | Parent space reference. |
| `depth` | `number \| undefined` | Nesting depth. |

## SpaceMemberPermissions

Included in `SpaceDetailed.memberPermissions` for authenticated users who are members.

| Property | Type | Description |
| - | - | - |
| `isAdmin` | `boolean` | Whether the user is an admin of this space. |
| `isModerator` | `boolean` | Whether the user is a moderator of this space. |
| `isMember` | `boolean` | Whether the user has an active membership. |
| `status` | `"pending" \| "active" \| "banned" \| null` | The user's membership status. |
| `canPost` | `boolean` | Whether the user may post entities in this space, given its `postingPermission`. For your app to enforce: the v7 API doesn't refuse entities because of it (see [Content inside a space](#content-inside-a-space)). |
| `canModerate` | `boolean` | Whether the user can perform moderation actions. |
| `canRead` | `boolean` | Whether the user may read content in this space, given its `readingPermission`. For your app to enforce: the v7 API doesn't hide content because of it (see [Content inside a space](#content-inside-a-space)). |

## Visibility

`visibility` is a distinct axis from `readingPermission`. **Visibility governs who can find and see the space object; reading permission says who may *read the content* inside it.** In v7, visibility hides the space record only, and `readingPermission` is for your app to enforce: neither hides the entities, comments or other content inside the space (see [Content inside a space](#content-inside-a-space)).

| Value | Behavior |
| - | - |
| `public` | **Default.** Listed in discovery and search (when every space above it is `public` too), and listed under its parent. |
| `unlisted` | Not listed in discovery or search, and listed under its parent only for its active members. Still reachable by direct link/slug/short ID by anyone who can see its parent, and joinable under the usual join/approval rules. |
| `private` | Hidden from everyone except its **active** members. To anyone else — including pending, banned and rejected members — it's never listed, it can't be joined, and reads, join and space-scoped routes answer `404` exactly as if the space didn't exist. The exceptions are [check my membership](https://docs.sublay.io/v7/api-reference/spaces/membership/check-my-membership.md), which still returns the caller's own membership row, and space chat, which answers `403` (see [Where it applies](#where-it-applies)). The content inside it stays readable (see [Content inside a space](#content-inside-a-space)). |

> [!NOTE]
>
> `unlisted` is **not access control.** It only affects discoverability — it does not restrict who can read the content inside the space. In v7, `private` and `readingPermission` don't restrict it either; see [Content inside a space](#content-inside-a-space).

### Who can see a space

A caller sees a space when they're an **active member** of it, or when it isn't `private` and they can see its parent. So the spaces under a `private` space are hidden too, except from the active members of that `private` space — and from the active members of a space further down, who see that space and what's under it.

The caller is the signed-in user. A service key that acts as a user (the `userId` or `actingUserId` the route takes, e.g. join, membership checks, user spaces, mutual spaces, event creation, reputation grants) sees what that user sees. A service key that doesn't act as a user sees every space.

Joining a `private` space answers `404`, and there's no endpoint that adds someone to it directly. People become active members of one in these ways:

* Creating it: the creator is its admin. The active admins and moderators of the space it's created under get the same role in it.
* A moderator [approving](https://docs.sublay.io/v7/api-reference/spaces/membership/approve-member.md) a join request that is still pending from when the user could see the space.
* A moderator [unbanning](https://docs.sublay.io/v7/api-reference/spaces/membership/unban-member.md) a banned member, which makes them active again.
* Being [given the admin or moderator role](https://docs.sublay.io/v7/api-reference/spaces/membership/update-member-role.md) in a space above it, which makes them an active member of every space under it, except where they're banned.

### Where it applies

* **Single reads** ([by ID](https://docs.sublay.io/v7/api-reference/spaces/fetch-space.md), [slug](https://docs.sublay.io/v7/api-reference/spaces/fetch-space-by-slug.md), [short ID](https://docs.sublay.io/v7/api-reference/spaces/fetch-space-by-short-id.md)), [join](https://docs.sublay.io/v7/api-reference/spaces/membership/join-space.md), [members](https://docs.sublay.io/v7/api-reference/spaces/membership/list-members.md), [team](https://docs.sublay.io/v7/api-reference/spaces/membership/list-team.md), [children](https://docs.sublay.io/v7/api-reference/spaces/fetch-children.md), [breadcrumb](https://docs.sublay.io/v7/api-reference/spaces/fetch-breadcrumb.md), [delete](https://docs.sublay.io/v7/api-reference/spaces/delete-space.md), creating a space under it, and every admin/moderator route: a space the caller can't see answers `404`, before any permission check.
* **[Check my membership](https://docs.sublay.io/v7/api-reference/spaces/membership/check-my-membership.md)** returns the caller's membership row in any status (so a banned user learns they're banned); with no row, a space they can't see answers `404`.
* **Rules**: a space the caller can't see has no rules — [list rules](https://docs.sublay.io/v7/api-reference/spaces/rules/list-rules.md) returns an empty list and [fetch rule](https://docs.sublay.io/v7/api-reference/spaces/rules/fetch-rule.md) answers `404`, as for a nonexistent space.
* **Lists across levels** ([Fetch Spaces](https://docs.sublay.io/v7/api-reference/spaces/fetch-spaces.md) without a specific parent, [space search](https://docs.sublay.io/v7/api-reference/search/search-spaces.md)): only spaces that are `public` and have only `public` spaces above them, for every caller.
* **Lists under one parent** ([Fetch Spaces](https://docs.sublay.io/v7/api-reference/spaces/fetch-spaces.md) with `parentSpaceId=<id>`, [Fetch Space Children](https://docs.sublay.io/v7/api-reference/spaces/fetch-children.md), the `childSpaces` preview and `childSpacesCount`): the sub-spaces the caller can see that are `public` or that they're an active member of. A service key that doesn't act as a user gets the `public` ones.
* **[User spaces](https://docs.sublay.io/v7/api-reference/spaces/fetch-user-spaces.md)** and **[mutual spaces](https://docs.sublay.io/v7/api-reference/spaces/fetch-mutual-spaces.md)** list only spaces that user can see; an active membership always counts. `memberOf=true` on Fetch Spaces returns the caller's own spaces regardless of visibility.
* **Embeds**: `parentSpace` on a space, and `space` on entities, comments and events (`include=space`), are `null` when the caller can't see that space; `parentSpaceId` / `spaceId` keep the id.
* **[Breadcrumb](https://docs.sublay.io/v7/api-reference/spaces/fetch-breadcrumb.md)**: the path starts just below the lowest space above that the caller can't see.
* **Space chat**: [Get Space Conversation](https://docs.sublay.io/v7/api-reference/spaces/chat/get-space-conversation.md) answers a space the caller can't see with `403 chat/not-a-member`, as it answers a nonexistent space, except that a caller banned in the space or a space above it gets `403 chat/banned`. The chat routes that take a conversation id answer a space chat in a space the caller can't see the way they answer someone who isn't in the conversation, even if the caller opened it before; it's left out of their conversation list and unread count, their real-time connection isn't subscribed to it when it connects or joins the conversation, and they get no push notifications for its new messages. Reporting a message in it, or a reputation grant on one, answers them the same way it answers someone who isn't in the conversation.
* **Event creation** in a space and **reputation grants** in a space answer a space the caller can't see exactly like a nonexistent one.

These are the only places visibility applies. The content inside a space the caller can't see isn't hidden; see [Content inside a space](#content-inside-a-space).

Visibility can be set on [create](https://docs.sublay.io/v7/api-reference/spaces/create-space.md) and [update](https://docs.sublay.io/v7/api-reference/spaces/update-space.md); changes take effect immediately and are reversible in both directions.

## Content inside a space

In v7, a space's settings protect the space itself, not the content inside it:

* **`private`** hides the space record, as described under [Where it applies](#where-it-applies). The content inside it stays readable through the v7 API: entities, comments and their reactions, events (which follow their own `visibility`), search and Ask results, collection entity lists, and notifications about that content. Only the `space` embedded on that content is `null` for a caller who can't see the space.
* **`readingPermission`** is stored and returned for your app to enforce. The v7 API reports it in `memberPermissions.canRead`, and applies it only to the [members](https://docs.sublay.io/v7/api-reference/spaces/membership/list-members.md) and [team](https://docs.sublay.io/v7/api-reference/spaces/membership/list-team.md) lists, which answer `403 space/members-access-denied` to anyone who isn't an active member of a `"members"` space. Content in a `"members"` space is returned to everyone, like content in an `"anyone"` space.
* **`postingPermission`** is stored and returned for your app to enforce. The v7 API reports it in `memberPermissions.canPost`, and doesn't refuse an entity or comment in the space because of it, or because the author is banned there. Creating an event in a space as a signed-in user needs an active membership of it (`403 event/not-space-member`); a service key skips that check.

> [!NOTE]
>
> In v8, private spaces and `readingPermission: "members"` protect the content too, and `postingPermission` and bans are enforced. See [Who can read content](https://docs.sublay.io/v8/data-models/space.md#who-can-read-content) and [Who can post and take part](https://docs.sublay.io/v8/data-models/space.md#who-can-post-and-take-part) in the v8 Space data model.

## NSFW flagging

NSFW is a separate axis from both `visibility` and `moderationStatus` — flagging a space (or entity) NSFW **labels** it, it does not hide or remove it. Every space carries its own `nsfw` boolean plus a denormalized `nsfwEffective`:

* **`nsfw`** — the space's own flag, defaulting to `false`. Toggled by space admins (via [create](https://docs.sublay.io/v7/hooks/spaces/use-create-space.md)/[update](https://docs.sublay.io/v7/hooks/spaces/use-update-space.md)) or by project admins from the dashboard.
* **`nsfwEffective`** — the denormalized rollup:

  ```
  nsfwEffective = own nsfw OR any ancestor space's nsfw
  ```

  It is maintained **on write**: creating a space under an NSFW parent inherits `nsfwEffective = true` even if its own `nsfw` is `false`, and toggling a space's own `nsfw` recomputes `nsfwEffective` top-down across its entire descendant subtree in the same transaction. A root space's `nsfwEffective` equals its own `nsfw`.

Because `nsfwEffective` folds in the whole ancestor chain, it is what an entity's live `nsfwEffective` reads from — flagging a space instantly cascades to every entity within it and its sub-spaces. See [Entity → NSFW flagging](https://docs.sublay.io/v7/data-models/entity.md#nsfw-flagging).

To filter a list by effective NSFW, pass `nsfwFilter` to [Fetch many spaces](https://docs.sublay.io/v7/hooks/spaces/use-fetch-many-spaces.md) (`include-all` default / `exclude` / `only`).

> [!NOTE]
>
> The space `nsfwFilter` keys off each space's own `nsfwEffective`, so `only` can return an NSFW child whose safe parent is omitted — results are **not** guaranteed to form a contiguous tree. Consumers building a tree from the result should not assume completeness.

> [!NOTE]
>
> Sublay only **labels** and **filters** NSFW content. It does **not** blur, age-gate, add interstitials, or store a per-viewer "show mature content" preference — presentation is the consuming app's responsibility.

## Related

* [Space Member data model](https://docs.sublay.io/v7/data-models/space-member.md)
* [useSpace hook](https://docs.sublay.io/v7/hooks/spaces/use-space.md)
* [Create Space API](https://docs.sublay.io/v7/api-reference/spaces/create-space.md)
* [Fetch Space API](https://docs.sublay.io/v7/api-reference/spaces/fetch-space.md)
* [Set space entity NSFW hook](https://docs.sublay.io/v7/hooks/spaces/use-set-space-entity-nsfw.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.