GoodMemGoodMem
ReferenceSdkV2.NET

Spaces

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.

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

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

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

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

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");


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.
PublicReadboolpublicReadIndicates if the space and its memories can be read by unauthenticated users or users other than the owner. Defaults to false. (optional)
OwnerIdstringownerIdOptional owner ID. If not provided, derived from the authentication context. Requires CREATE_SPACE_ANY permission if specified. (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.
PublicReadboolpublicReadWhether this space is publicly readable by all users.
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)

UpdateSpaceRequest

Request parameters for updating a space.

PropertyTypeJSON (wire)Description
NamestringnameThe new name for the space. (optional)
PublicReadboolpublicReadWhether the space is publicly readable by all users. (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)