GoodMemGoodMem

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 the authenticated principal unless ownerId is provided; CREATE_SPACE is evaluated against the proposed space and owner.

EMBEDDER REQUIREMENTS: At least one embedder configuration must be specified. Every referenced embedder must exist, and the caller must have EXECUTE_EMBEDDER on each one.

DUPLICATE DETECTION: Returns ALREADY_EXISTS if another space exists with identical {ownerId, name} (case-sensitive). This operation is NOT idempotent.

HTTP: POST /v1/spaces

Parameters

ParameterTypeDescription
requestSpaceCreationRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;SpaceResponseShape&gt;

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 on the requested space. This operation is safe to retry and may return NOT_FOUND if the space was already deleted.

HTTP: DELETE /v1/spaces/&#123;id&#125;

Parameters

ParameterTypeDescription
idstringThe unique identifier of the space to delete
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;void&gt;

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. Requires READ_SPACE on the requested space. The service distinguishes a missing space from an existing space the caller cannot read. This is a read-only operation safe to retry.

HTTP: GET /v1/spaces/&#123;id&#125;

Parameters

ParameterTypeDescription
idstringThe unique identifier of the space to retrieve
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;SpaceResponseShape&gt;

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).

AUTHORIZATION: Requires LIST_SPACE on the GoodMem instance. Each returned space must also be visible through READ_SPACE; unauthorized spaces are filtered in PostgreSQL. The ownerId parameter filters that already-authorized result set and does not grant additional visibility.

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.

HTTP: GET /v1/spaces

Parameters

ParameterTypeDescription
optionsSpacesListOptions optionalOptional query parameters.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;Page&lt;SpaceResponseShape&gt;&gt;

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.transferOwnership

client.spaces.transferOwnership(id: string, request: TransferOwnershipRequest, requestOptions?: RequestOptions): Promise<TransferSpaceOwnershipResponseShape>

Transfers an existing space to another active human or service principal. The current space owner, the GoodMem instance owner, or an instance administrator may transfer it; a space-scoped administrator cannot. Only owner and update-audit fields change. Memories, embedder associations, grants, and role assignments remain unchanged. This operation is not idempotent under response semantics: after an unknown outcome, read the space before retrying.

HTTP: POST /v1/spaces/&#123;id&#125;:transferOwnership

Parameters

ParameterTypeDescription
idstringUUID of the existing space to transfer
requestTransferOwnershipRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;TransferSpaceOwnershipResponseShape&gt;

Example

const transferredSpace = await client.spaces.transferOwnership(policySpaceId, {
  newOwnerId: principalId,
});

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 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 an existing space. Requires UPDATE_SPACE on the requested space. This operation is idempotent.

HTTP: PUT /v1/spaces/&#123;id&#125;

Parameters

ParameterTypeDescription
idstringThe unique identifier of the space to update
requestUpdateSpaceRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;SpaceResponseShape&gt;

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.

FieldTypeRequiredDescription
spacesArray&lt;Space&gt;yesThe list of spaces matching the query criteria.
nextTokenstring | nullnoPagination 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.

FieldTypeRequiredDescription
spaceIdstringyesThe UUID for this space.
namestringyesThe name of the space.
labelsRecord&lt;string, string&gt;yesKey-value pairs of metadata associated with the space.
spaceEmbeddersArray&lt;SpaceEmbedder&gt;yesThe list of embedders associated with this space.
createdAtnumberyesTimestamp when this space was created (milliseconds since epoch).
updatedAtnumberyesTimestamp when this space was last updated (milliseconds since epoch).
ownerIdstringyesThe ID of the user who owns this space.
createdByIdstringyesThe ID of the user who created this space.
updatedByIdstringyesThe ID of the user who last updated this space.
defaultChunkingConfigChunkingConfiguration | nullnoDefault 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.

FieldTypeRequiredDescription
namestringyesThe desired name for the space. Must be unique within the user's scope.
labelsRecord&lt;string, string&gt; | nullnoA set of key-value pairs to categorize or tag the space. Used for filtering and organizational purposes.
spaceEmbeddersArray&lt;SpaceEmbedderConfig&gt;yesList 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.
ownerIdstring | nullnoOptional owner principal UUID. If omitted, defaults to the authenticated principal. CREATE_SPACE is evaluated against the proposed space and owner.
defaultChunkingConfigChunkingConfigurationyesDefault chunking strategy for memories in this space
spaceIdstring | nullnoOptional 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.

FieldTypeRequiredDescription
spaceIdstringyesThe UUID for the space.
embedderIdstringyesThe UUID for the embedder.
defaultRetrievalWeightnumberyesThe default weight for this embedder during retrieval operations.
createdAtnumberyesTimestamp when this association was created (milliseconds since epoch).
updatedAtnumberyesTimestamp when this association was last updated (milliseconds since epoch).
createdByIdstringyesThe ID of the user who created this association.
updatedByIdstringyesThe ID of the user who last updated this association.

SpaceEmbedderConfig

Configuration for associating an embedder with a space.

FieldTypeRequiredDescription
embedderIdstringyesThe UUID for the embedder to associate with the space.
defaultRetrievalWeightnumber | nullnoRelative 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.

TransferSpaceOwnershipResponse

The space after its ownership transfer completes.

FieldTypeRequiredDescription
spaceSpaceyesUpdated space with its new owner and audit metadata.

UpdateSpaceRequest

Request parameters for updating a space.

FieldTypeRequiredDescription
namestring | nullnoThe new name for the space.
replaceLabelsRecord&lt;string, string&gt; | nullnoLabels to replace all existing labels. Mutually exclusive with mergeLabels.
mergeLabelsRecord&lt;string, string&gt; | nullnoLabels 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

FieldTypeRequiredDescription
spacesArray&lt;SpaceResponseShape&gt;yesThe list of spaces matching the query criteria.
nextTokenstring | nullnoPagination token for retrieving the next set of results. Only present if there are more results available.

SpaceResponseShape

FieldTypeRequiredDescription
spaceIdstringyesThe UUID for this space.
namestringyesThe name of the space.
labelsRecord&lt;string, string&gt;yesKey-value pairs of metadata associated with the space.
spaceEmbeddersArray&lt;SpaceEmbedderResponseShape&gt;yesThe list of embedders associated with this space.
createdAtnumberyesTimestamp when this space was created (milliseconds since epoch).
updatedAtnumberyesTimestamp when this space was last updated (milliseconds since epoch).
ownerIdstringyesThe ID of the user who owns this space.
createdByIdstringyesThe ID of the user who created this space.
updatedByIdstringyesThe ID of the user who last updated this space.
defaultChunkingConfigChunkingConfigurationResponseShape | nullnoDefault chunking strategy for memories in this space

SpaceEmbedderResponseShape

FieldTypeRequiredDescription
spaceIdstringyesThe UUID for the space.
embedderIdstringyesThe UUID for the embedder.
defaultRetrievalWeightnumberyesThe default weight for this embedder during retrieval operations.
createdAtnumberyesTimestamp when this association was created (milliseconds since epoch).
updatedAtnumberyesTimestamp when this association was last updated (milliseconds since epoch).
createdByIdstringyesThe ID of the user who created this association.
updatedByIdstringyesThe ID of the user who last updated this association.

TransferSpaceOwnershipResponseShape

FieldTypeRequiredDescription
spaceSpaceResponseShapeyesUpdated space with its new owner and audit metadata.