Skip to main content

Overview

Creates a new space owned by the authenticated user. You must provide a title, description, and at least one hashtag. Visibility defaults to "public" if not specified.

Endpoint

POST /api/spaces
Requires authentication. Include a Bearer token in the Authorization header.

Request

Body parameters

title
string
required
The display title for the space.
description
string
required
A short description of what the space is about.
visibility
string
Controls who can find and join the space. Accepted values: "public" or "private". Defaults to "public".
hashtags
string[]
required
An array of hashtag strings to tag the space. Used for discovery and search.

Response

Returns the newly created Space object.
space_id
string
Unique identifier assigned to the new space.
title
string
The title you provided.
description
string
The description you provided.
visibility
string
The visibility of the created space: "public" or "private".
creator
object
The authenticated user who created the space.
participant_count
number
Number of participants. Typically 1 immediately after creation.
tags
array
Tags derived from the hashtags you provided.

Example

TypeScript
import { createSpace } from "./api/Spaces";

const newSpace = await createSpace({
  title: "TypeScript Tips",
  description: "A space for sharing TypeScript patterns and best practices.",
  visibility: "public",
  hashtags: ["typescript", "programming", "webdev"],
});

console.log(newSpace);
// {
//   space_id: "new001",
//   title: "TypeScript Tips",
//   description: "A space for sharing TypeScript patterns and best practices.",
//   visibility: "public",
//   creator: { user_id: "u1", username: "alice", profile_picture: "https://..." },
//   participant_count: 1,
//   tags: [
//     { tag_id: 10, tag_name: "typescript" },
//     { tag_id: 11, tag_name: "programming" },
//     { tag_id: 12, tag_name: "webdev" }
//   ]
// }