Spaces
Memory space management.
Methods on this page are called through client.spaces.
client.spaces.create
client.spaces.create(request: SpaceCreationRequest, requestOptions?: RequestOptions): Promise<SpaceResponseShape>Creates a new space with the provided name, labels, and embedder configuration. A space is a container for organizing related memories. OWNER DEFAULTS: Owner defaults to authenticated user unless ownerId is provided (requires CREATE_SPACE_ANY if differs). EMBEDDER REQUIREMENTS: At least one embedder configuration must be specified. DUPLICATE DETECTION: Returns ALREADY_EXISTS if another space exists with identical {ownerId, name} (case-sensitive). Requires CREATE_SPACE_OWN permission (or CREATE_SPACE_ANY for admin users). This operation is NOT idempotent.
HTTP: POST /v1/spaces
Parameters
| Parameter | Type | Description |
|---|---|---|
request | SpaceCreationRequest | Request body. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<SpaceResponseShape>
Example
const space = await client.spaces.create({
name: "Doc Space",
spaceEmbedders: [{ embedderId: "your-embedder-id" }],
labels: { env: "docs" },
});client.spaces.delete
client.spaces.delete(id: string, requestOptions?: RequestOptions): Promise<void>Permanently deletes a space and all associated content. This operation cannot be undone. CASCADE DELETION: Removes the space record and cascades deletion to associated memories, chunks, and embedder associations. Requires DELETE_SPACE_OWN permission for spaces you own (or DELETE_SPACE_ANY for admin users). This operation is safe to retry - may return NOT_FOUND if already deleted.
HTTP: DELETE /v1/spaces/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the space to delete |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<void>
Example
await client.spaces.delete("your-space-id");client.spaces.get
client.spaces.get(id: string, requestOptions?: RequestOptions): Promise<SpaceResponseShape>Retrieves a specific space by its unique identifier. Returns the complete space information, including name, labels, embedder configuration, and metadata. PUBLIC SPACE ACCESS: When public_read=true, any authenticated user can retrieve the space metadata, bypassing ownership checks. Otherwise, requires ownership or DISPLAY_SPACE_ANY permission. Requires DISPLAY_SPACE_OWN permission for owned spaces (or DISPLAY_SPACE_ANY for admin users to view any space). This is a read-only operation safe to retry.
HTTP: GET /v1/spaces/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the space to retrieve |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<SpaceResponseShape>
Example
const fetchedSpace = await client.spaces.get("your-space-id");
console.log(fetchedSpace.name);client.spaces.list
client.spaces.list(options?: SpacesListOptions, requestOptions?: RequestOptions): Promise<Page<SpaceResponseShape>>Retrieves a list of spaces accessible to the caller, with optional filtering by owner, labels, and name. Results are paginated with a maximum number of spaces per response. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_SPACE_ANY and ownerId omitted, returns all visible spaces; otherwise returns caller-owned spaces only. DEFAULT SORT: Results ordered by created_at DESCENDING unless specified otherwise. MAX_RESULTS CLAMPING: maxResults defaults to 50 and is clamped to [1, 1000] range. Requires LIST_SPACE_OWN or LIST_SPACE_ANY permission.
HTTP: GET /v1/spaces
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SpacesListOptions optional | Optional query parameters. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<Page<SpaceResponseShape>>
Example
Example 1:
for await (const item of await client.spaces.list()) {
console.log(item.spaceId, item.name);
}Example 2:
let seenSpaces = 0;
for await (const item of await client.spaces.list({ maxResults: 10 })) {
console.log(item.name);
if (++seenSpaces === 20) break;
}Example 3:
const spacesPage = await client.spaces.list({ maxResults: 10 });
for (const item of spacesPage.items) {
console.log(item.name);
}
if (spacesPage.nextToken) {
await client.spaces.list({ nextToken: spacesPage.nextToken });
}Example 4:
let token: string | undefined;
for (let pageCount = 0; pageCount < 3; pageCount++) {
const nextPage = await client.spaces.list({ maxResults: 10, nextToken: token });
console.log(nextPage.items.length);
token = nextPage.nextToken;
if (!token) break;
}Example 5:
let emitted = 0;
for await (const item of await client.spaces.list()) {
console.log(item.spaceId);
if (++emitted >= 25) break;
}Example 6:
const page = await client.spaces.list({ maxResults: 10 });
console.log(page.items.length, page.nextToken);Example 7:
let cappedSpaces = 0;
for await (const item of await client.spaces.list({ maxResults: 5 })) {
console.log(item.name);
if (++cappedSpaces >= 12) break;
}Example 8:
const firstSpacesPage = await client.spaces.list({ maxResults: 10 });
const resumedSpacesPage = await client.spaces.list({ nextToken: firstSpacesPage.nextToken });
console.log(resumedSpacesPage.items.length);Example 9:
const resumeFrom = "opaque-next-token";
let resumedCount = 0;
for await (const item of await client.spaces.list({ nextToken: resumeFrom, maxResults: 10 })) {
console.log(item.spaceId);
if (++resumedCount >= 20) break;
}client.spaces.update
client.spaces.update(id: string, request: UpdateSpaceRequest, requestOptions?: RequestOptions): Promise<SpaceResponseShape>Updates an existing space with new values for the specified fields. Only name, publicRead, and labels can be updated. Fields not included in the request remain unchanged. IMMUTABLE FIELDS: space_embedders, default_chunking_config, and ownerId cannot be modified after creation. NAME UNIQUENESS: Name must be unique per owner - returns ALREADY_EXISTS if name conflicts with existing space. Requires UPDATE_SPACE_OWN permission for spaces you own (or UPDATE_SPACE_ANY for admin users). This operation is idempotent.
HTTP: PUT /v1/spaces/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the space to update |
request | UpdateSpaceRequest | Request body. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<SpaceResponseShape>
Example
const updatedSpace = await client.spaces.update("your-space-id", {
name: "Doc Space (updated)",
mergeLabels: { version: "2" },
});
console.log(updatedSpace.spaceId);Data Models
Interfaces
ListSpacesResponse
Response containing a list of spaces and optional pagination token.
| Field | Type | Required | Description |
|---|---|---|---|
spaces | Array<Space> | yes | The list of spaces matching the query criteria. |
nextToken | string | null | no | Pagination token for retrieving the next set of results. Only present if there are more results available. |
Space
A Space is a container for organizing related memories with vector embeddings.
| Field | Type | Required | Description |
|---|---|---|---|
spaceId | string | yes | The UUID for this space. |
name | string | yes | The name of the space. |
labels | Record<string, string> | yes | Key-value pairs of metadata associated with the space. |
spaceEmbedders | Array<SpaceEmbedder> | yes | The list of embedders associated with this space. |
createdAt | number | yes | Timestamp when this space was created (milliseconds since epoch). |
updatedAt | number | yes | Timestamp when this space was last updated (milliseconds since epoch). |
ownerId | string | yes | The ID of the user who owns this space. |
createdById | string | yes | The ID of the user who created this space. |
updatedById | string | yes | The ID of the user who last updated this space. |
publicRead | boolean | yes | Whether this space is publicly readable by all users. |
defaultChunkingConfig | ChunkingConfiguration | null | no | Default chunking strategy for memories in this space |
SpaceCreationRequest
Request body for creating a new Space. A Space is a container for organizing related memories with vector embeddings.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | The desired name for the space. Must be unique within the user's scope. |
labels | Record<string, string> | null | no | A set of key-value pairs to categorize or tag the space. Used for filtering and organizational purposes. |
spaceEmbedders | Array<SpaceEmbedderConfig> | yes | List of embedder configurations to associate with this space. At least one embedder configuration is required. Each specifies an embedder ID and a relative default retrieval weight used when no per-request overrides are provided. |
publicRead | boolean | null | no | Indicates if the space and its memories can be read by unauthenticated users or users other than the owner. Defaults to false. |
ownerId | string | null | no | Optional owner ID. If not provided, derived from the authentication context. Requires CREATE_SPACE_ANY permission if specified. |
defaultChunkingConfig | ChunkingConfiguration | yes | Default chunking strategy for memories in this space |
spaceId | string | null | no | Optional client-provided UUID for idempotent creation. If not provided, server generates a new UUID. Returns ALREADY_EXISTS if ID is already in use. |
SpaceEmbedder
Associates an embedder with a space, including retrieval configuration.
| Field | Type | Required | Description |
|---|---|---|---|
spaceId | string | yes | The UUID for the space. |
embedderId | string | yes | The UUID for the embedder. |
defaultRetrievalWeight | number | yes | The default weight for this embedder during retrieval operations. |
createdAt | number | yes | Timestamp when this association was created (milliseconds since epoch). |
updatedAt | number | yes | Timestamp when this association was last updated (milliseconds since epoch). |
createdById | string | yes | The ID of the user who created this association. |
updatedById | string | yes | The ID of the user who last updated this association. |
SpaceEmbedderConfig
Configuration for associating an embedder with a space.
| Field | Type | Required | Description |
|---|---|---|---|
embedderId | string | yes | The UUID for the embedder to associate with the space. |
defaultRetrievalWeight | number | null | no | Relative weight for this embedder used by default during retrieval. If omitted, defaults to 1.0; values need not sum to 1 and can be overridden per request. |
UpdateSpaceRequest
Request parameters for updating a space.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | null | no | The new name for the space. |
publicRead | boolean | null | no | Whether the space is publicly readable by all users. |
replaceLabels | Record<string, string> | null | no | Labels to replace all existing labels. Mutually exclusive with mergeLabels. |
mergeLabels | Record<string, string> | null | no | Labels to merge with existing labels. Mutually exclusive with replaceLabels. |
Response Shapes
Response shape types model values returned by the SDK after forward-compatible unknown enum strings are coerced to null.
ListSpacesResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
spaces | Array<SpaceResponseShape> | yes | The list of spaces matching the query criteria. |
nextToken | string | null | no | Pagination token for retrieving the next set of results. Only present if there are more results available. |
SpaceResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
spaceId | string | yes | The UUID for this space. |
name | string | yes | The name of the space. |
labels | Record<string, string> | yes | Key-value pairs of metadata associated with the space. |
spaceEmbedders | Array<SpaceEmbedderResponseShape> | yes | The list of embedders associated with this space. |
createdAt | number | yes | Timestamp when this space was created (milliseconds since epoch). |
updatedAt | number | yes | Timestamp when this space was last updated (milliseconds since epoch). |
ownerId | string | yes | The ID of the user who owns this space. |
createdById | string | yes | The ID of the user who created this space. |
updatedById | string | yes | The ID of the user who last updated this space. |
publicRead | boolean | yes | Whether this space is publicly readable by all users. |
defaultChunkingConfig | ChunkingConfigurationResponseShape | null | no | Default chunking strategy for memories in this space |
SpaceEmbedderResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
spaceId | string | yes | The UUID for the space. |
embedderId | string | yes | The UUID for the embedder. |
defaultRetrievalWeight | number | yes | The default weight for this embedder during retrieval operations. |
createdAt | number | yes | Timestamp when this association was created (milliseconds since epoch). |
updatedAt | number | yes | Timestamp when this association was last updated (milliseconds since epoch). |
createdById | string | yes | The ID of the user who created this association. |
updatedById | string | yes | The ID of the user who last updated this association. |