Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sam-shervin/space7/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Returns a paginated list of messages posted in a given space. Results can be sorted by most recent or most appreciated.

Endpoint

GET /api/messages/:spaceId
Requires authentication

Request

Path parameters

spaceId
string
required
The unique identifier of the space to fetch messages from.

Query parameters

sort
string
Sort order for messages. Accepted values: "recent" or "most_appreciated". Defaults to "recent".
page
number
Page number for pagination. Defaults to 1.
limit
number
Number of messages to return per page. Defaults to 50.

Response

Returns a MessagesResponse object.
messages
Message[]
Array of message objects.
total
number
Total number of messages in the space.
page
number
Current page number.
totalPages
number
Total number of pages available.

Example

TypeScript
import { fetchWithAuth } from "./fetchWithAuth";

const getMessages = async (
  spaceId: string,
  options: { sort?: "recent" | "most_appreciated"; page?: number; limit?: number } = {},
) => {
  const sort = options.sort ?? "recent";
  const page = options.page ?? 1;
  const limit = options.limit ?? 50;
  const query = `?sort=${sort}&page=${page}&limit=${limit}`;

  const res = await fetchWithAuth(`/api/messages/${spaceId}${query}`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  });

  const data = await res.json();

  if (!res.ok) {
    throw new Error(data.error || "Failed to fetch messages");
  }

  return data; // MessagesResponse
};

Build docs developers (and LLMs) love