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

createSpace

Creates a new space.
const space = await replyke.spaces.createSpace({
  userId: "usr_abc123",
  name: "Photography",
  slug: "photography",
  description: "A community for photographers",
  postingPermission: "members",
});
userId
string
required
The Replyke user ID of the space creator, who becomes the initial admin.
name
string
required
Display name for the space.
slug
string
URL-friendly identifier. Must be unique within the project. Generated from name if omitted.
description
string
Short description of the space.
readingPermission
string
Who can read content: "anyone" (default) or "members".
postingPermission
string
Who can post content: "anyone", "members" (default), or "admins".
requireJoinApproval
boolean
When true, join requests must be manually approved. Defaults to false.
parentSpaceId
string
Makes this space a child of the specified parent space.
metadata
object
Arbitrary metadata attached to the space.
ReturnsPromise<Space>

fetchSpace

Fetches a space by its Replyke ID, including member counts and permission details.
const space = await replyke.spaces.fetchSpace({ spaceId: "spc_abc123" });
spaceId
string
required
The Replyke space ID.
ReturnsPromise<SpaceDetailed>

fetchManySpaces

Fetches a paginated list of top-level spaces, with optional text search.
const { data, metadata } = await replyke.spaces.fetchManySpaces({
  page: 1,
  limit: 20,
  query: "photo",
});
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
parentSpaceId
string
When provided, fetches children of this space instead of top-level spaces.
query
string
Text search query to filter spaces by name.
ReturnsPromise<PaginatedResponse<Space>>

fetchSpaceBySlug

Fetches a space by its unique slug.
const space = await replyke.spaces.fetchSpaceBySlug({ slug: "photography" });
slug
string
required
The space’s URL slug.
ReturnsPromise<SpaceDetailed>

fetchSpaceByShortId

Fetches a space by its short, human-readable ID (used in share URLs).
const space = await replyke.spaces.fetchSpaceByShortId({ shortId: "ph3x9" });
shortId
string
required
The space’s short ID.
ReturnsPromise<SpaceDetailed>

fetchUserSpaces

Fetches the spaces a specific user is a member of.
const result = await replyke.spaces.fetchUserSpaces({
  userId: "usr_abc123",
  page: 1,
  limit: 20,
});
userId
string
required
The Replyke user ID.
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<UserSpacesResponse>

updateSpace

Updates settings on an existing space.
const space = await replyke.spaces.updateSpace({
  spaceId: "spc_abc123",
  name: "Photography Community",
  postingPermission: "admins",
  requireJoinApproval: true,
});
spaceId
string
required
The Replyke space ID to update.
name
string
New display name.
slug
string
New slug. Must be unique.
description
string
New description.
readingPermission
string
Updated reading permission: "anyone" or "members".
postingPermission
string
Updated posting permission: "anyone", "members", or "admins".
requireJoinApproval
boolean
Updated join approval requirement.
metadata
object
Updated metadata. Merged with existing values.
ReturnsPromise<Space>

deleteSpace

Permanently deletes a space and all its content.
const result = await replyke.spaces.deleteSpace({ spaceId: "spc_abc123" });
spaceId
string
required
The Replyke space ID to delete.
ReturnsPromise<DeleteSpaceResponse>

checkSlugAvailability

Checks whether a slug is available for use.
const { available } = await replyke.spaces.checkSlugAvailability({
  slug: "photography",
});
slug
string
required
The slug to check.
ReturnsPromise<{ available: boolean }>

fetchChildSpaces

Fetches the direct child spaces of a given parent space.
const { data, metadata } = await replyke.spaces.fetchChildSpaces({
  spaceId: "spc_abc123",
  page: 1,
  limit: 20,
});
spaceId
string
required
The parent Replyke space ID.
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<Space>>

fetchSpaceBreadcrumb

Returns the full ancestor chain from the root down to the specified space. Useful for rendering breadcrumb navigation.
const breadcrumb = await replyke.spaces.fetchSpaceBreadcrumb({
  spaceId: "spc_abc123",
});
// [{ id: "root", name: "Root" }, { id: "spc_parent", name: "Parent" }, { id: "spc_abc123", name: "Photography" }]
spaceId
string
required
The Replyke space ID to get the breadcrumb for.
ReturnsPromise<SpaceBreadcrumb>