GoodMemGoodMem
ReferenceClient SDKs.NET

Spaces

.NET SDK reference for memory spaces: ownership transfer, creation, lookup, listing, updates, and deletion.

Memory space management — the top-level container for memories.

Namespace: Goodmem.Client.Api · Class: SpacesApi

Reach this surface as client.Spaces on a GoodmemClient. Every network method is asynchronous — it returns a Task<T> (or an IAsyncEnumerable<T> for pagination and streaming) and accepts a CancellationToken; the Async suffix marks the standard .NET Task-based async pattern.

Methods

MethodSummary
CreateAsyncCreate a new Space.
GetAsyncGet a space by ID.
ListAsyncList spaces.
UpdateAsyncUpdate a space.
DeleteAsyncDelete a space.
TransferOwnershipAsyncTransfer ownership of a space.

CreateAsync

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.

Declaration

public Task<Space> CreateAsync(SpaceCreationRequest request, CancellationToken ct = default)

HTTPPOST /v1/spaces

Parameters

TypeNameDescription
SpaceCreationRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<Space> — an awaitable that resolves to Space.

Exceptions

TypeCondition
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var space = await client.Spaces.CreateAsync(
    new SpaceCreationRequest
    {
        Name = "Doc Space",
        SpaceEmbedders = new[]
        {
            new SpaceEmbedderConfig
            {
                EmbedderId = "your-embedder-id",
                DefaultRetrievalWeight = 1.0,
            },
        },
        Labels = new Dictionary<string, string> { ["env"] = "docs" },
    }
);
Console.WriteLine(space.SpaceId);


GetAsync

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.

Declaration

public Task<Space> GetAsync(string id, CancellationToken ct = default)

HTTPGET /v1/spaces/&#123;id&#125;

Parameters

TypeNameDescription
stringidThe unique identifier of the space to retrieve
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<Space> — an awaitable that resolves to Space.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var space = await client.Spaces.GetAsync("your-space-id");
Console.WriteLine(space.Name);


ListAsync

List spaces accessible to the caller, with optional filtering by owner, labels, and name. Results are paginated; pass the response's nextToken back as a query parameter to fetch subsequent pages.

Declaration

public IAsyncEnumerable<Space> ListAsync(SpacesListOptions? options = null, CancellationToken ct = default)

HTTPGET /v1/spaces

Parameters

TypeNameDescription
SpacesListOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

IAsyncEnumerable<Space> — an async stream; await foreach yields each Space across pages / events.

Exceptions

TypeCondition
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Examples

Example 1:

// Auto-paginate every space; the SDK fetches the next page on demand as you iterate.
await foreach (var space in client.Spaces.ListAsync())
    Console.WriteLine($"{space.SpaceId} {space.Name}");

Example 2:

// Auto-paginate but stop after 2 items total.
var count = 0;
await foreach (var space in client.Spaces.ListAsync())
{
    if (count >= 2)
        break;
    Console.WriteLine(space.SpaceId);
    count++;
}

Example 3:

// Process results a page at a time. MaxResults sets the server page size; the SDK
// fetches the next page on demand as you iterate.
var page = new List<Space>();
await foreach (
    var space in client.Spaces.ListAsync(new SpacesListOptions { MaxResults = 5 })
)
{
    page.Add(space);
    if (page.Count == 5)
    {
        // ... handle this page of results ...
        page.Clear();
    }
}
if (page.Count > 0)
{
    // ... handle the final partial page ...
}

Example 4:

// Page-at-a-time processing with a total cap across all pages.
var seen = 0;
var page = new List<Space>();
await foreach (
    var space in client.Spaces.ListAsync(new SpacesListOptions { MaxResults = 2 })
)
{
    page.Add(space);
    seen++;
    if (page.Count == 2)
        page.Clear();
    if (seen >= 2)
        break;
}

Example 5:

// Cap how many items you consume, regardless of page size.
var spaces = new List<Space>();
await foreach (var space in client.Spaces.ListAsync())
{
    if (spaces.Count >= 3)
        break;
    spaces.Add(space);
}

Example 6:

// MaxResults controls how many items the server returns per network call.
await foreach (
    var space in client.Spaces.ListAsync(new SpacesListOptions { MaxResults = 5 })
)
    Console.WriteLine(space.Name);

Example 7:

// Server batch size (MaxResults) and a client-side cap are independent:
// fetch 2 per API call, stop after 5 items total.
var count = 0;
await foreach (
    var space in client.Spaces.ListAsync(new SpacesListOptions { MaxResults = 2 })
)
{
    if (count >= 5)
        break;
    Console.WriteLine(space.SpaceId);
    count++;
}

Example 8:

// Resume from a pagination token you saved from an earlier page.
var savedToken = "your-saved-token";
await foreach (
    var space in client.Spaces.ListAsync(
        new SpacesListOptions { NextToken = savedToken }
    )
)
    Console.WriteLine(space.Name);

Example 9:

// Resume from a saved token but consume at most 10 more items.
var savedToken = "your-saved-token";
var count = 0;
await foreach (
    var space in client.Spaces.ListAsync(
        new SpacesListOptions { NextToken = savedToken }
    )
)
{
    if (count >= 10)
        break;
    Console.WriteLine(space.Name);
    count++;
}


UpdateAsync

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.

Declaration

public Task<Space> UpdateAsync(string id, UpdateSpaceRequest request, CancellationToken ct = default)

HTTPPUT /v1/spaces/&#123;id&#125;

Parameters

TypeNameDescription
stringidThe unique identifier of the space to update
UpdateSpaceRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<Space> — an awaitable that resolves to Space.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var updated = await client.Spaces.UpdateAsync(
    "your-space-id",
    new UpdateSpaceRequest
    {
        Name = "Doc Space (updated)",
        MergeLabels = new Dictionary<string, string> { ["version"] = "2" },
    }
);
Console.WriteLine(updated.SpaceId);


DeleteAsync

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.

Declaration

public Task DeleteAsync(string id, CancellationToken ct = default)

HTTPDELETE /v1/spaces/&#123;id&#125;

Parameters

TypeNameDescription
stringidThe unique identifier of the space to delete
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task — completes when the operation finishes; there is no response body.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

await client.Spaces.DeleteAsync("your-space-id");


TransferOwnershipAsync

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.

Declaration

public Task<TransferSpaceOwnershipResponse> TransferOwnershipAsync(string id, TransferOwnershipRequest request, CancellationToken ct = default)

HTTPPOST /v1/spaces/&#123;id&#125;:transferOwnership

Parameters

TypeNameDescription
stringidUUID of the existing space to transfer
TransferOwnershipRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<TransferSpaceOwnershipResponse> — an awaitable that resolves to TransferSpaceOwnershipResponse.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var transferredSpace = await client.Spaces.TransferOwnershipAsync(
    spaceId,
    new TransferOwnershipRequest { NewOwnerId = "your-principal-id" }
);


Data Models

Types in the Goodmem.Client.Models namespace. Each row lists the C# property, its type, the JSON wire name, and a description.

SpaceCreationRequest

Request body for creating a new Space. A Space is a container for organizing related memories with vector embeddings.

PropertyTypeJSON (wire)Description
NamestringnameThe desired name for the space. Must be unique within the user's scope.
LabelsIReadOnlyDictionary<string, string>labelsA set of key-value pairs to categorize or tag the space. Used for filtering and organizational purposes. (optional)
SpaceEmbeddersIReadOnlyList<SpaceEmbedderConfig>spaceEmbeddersList 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.
OwnerIdstringownerIdOptional owner principal UUID. If omitted, defaults to the authenticated principal. CREATE_SPACE is evaluated against the proposed space and owner. (optional)
DefaultChunkingConfigChunkingConfigurationdefaultChunkingConfigDefault chunking strategy for memories in this space
SpaceIdstringspaceIdOptional client-provided UUID for idempotent creation. If not provided, server generates a new UUID. Returns ALREADY_EXISTS if ID is already in use. (optional)

SpaceEmbedderConfig

Configuration for associating an embedder with a space.

PropertyTypeJSON (wire)Description
EmbedderIdstringembedderIdThe UUID for the embedder to associate with the space.
DefaultRetrievalWeightdoubledefaultRetrievalWeightRelative 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. (optional)

Space

A Space is a container for organizing related memories with vector embeddings.

PropertyTypeJSON (wire)Description
SpaceIdstringspaceIdThe UUID for this space.
NamestringnameThe name of the space.
LabelsIReadOnlyDictionary<string, string>labelsKey-value pairs of metadata associated with the space.
SpaceEmbeddersIReadOnlyList<SpaceEmbedder>spaceEmbeddersThe list of embedders associated with this space.
CreatedAtDateTimeOffsetcreatedAtTimestamp when this space was created (milliseconds since epoch).
UpdatedAtDateTimeOffsetupdatedAtTimestamp when this space was last updated (milliseconds since epoch).
OwnerIdstringownerIdThe ID of the user who owns this space.
CreatedByIdstringcreatedByIdThe ID of the user who created this space.
UpdatedByIdstringupdatedByIdThe ID of the user who last updated this space.
DefaultChunkingConfigChunkingConfigurationdefaultChunkingConfigDefault chunking strategy for memories in this space (optional)

SpaceEmbedder

Associates an embedder with a space, including retrieval configuration.

PropertyTypeJSON (wire)Description
SpaceIdstringspaceIdThe UUID for the space.
EmbedderIdstringembedderIdThe UUID for the embedder.
DefaultRetrievalWeightdoubledefaultRetrievalWeightThe default weight for this embedder during retrieval operations.
CreatedAtDateTimeOffsetcreatedAtTimestamp when this association was created (milliseconds since epoch).
UpdatedAtDateTimeOffsetupdatedAtTimestamp when this association was last updated (milliseconds since epoch).
CreatedByIdstringcreatedByIdThe ID of the user who created this association.
UpdatedByIdstringupdatedByIdThe ID of the user who last updated this association.

ListSpacesResponse

Response containing a list of spaces and optional pagination token.

PropertyTypeJSON (wire)Description
SpacesIReadOnlyList<Space>spacesThe list of spaces matching the query criteria.
NextTokenstringnextTokenPagination token for retrieving the next set of results. Only present if there are more results available. (optional)

TransferSpaceOwnershipResponse

The space after its ownership transfer completes.

PropertyTypeJSON (wire)Description
SpaceSpacespaceUpdated space with its new owner and audit metadata.

UpdateSpaceRequest

Request parameters for updating a space.

PropertyTypeJSON (wire)Description
NamestringnameThe new name for the space. (optional)
ReplaceLabelsIReadOnlyDictionary<string, string>replaceLabelsLabels to replace all existing labels. Mutually exclusive with mergeLabels. (optional)
MergeLabelsIReadOnlyDictionary<string, string>mergeLabelsLabels to merge with existing labels. Mutually exclusive with replaceLabels. (optional)