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
| Method | Summary |
|---|---|
CreateAsync | Create a new Space. |
GetAsync | Get a space by ID. |
ListAsync | List spaces. |
UpdateAsync | Update a space. |
DeleteAsync | Delete 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)
HTTP — POST /v1/spaces
Parameters
| Type | Name | Description |
|---|---|---|
SpaceCreationRequest | request | The request payload; the linked model lists every field and its JSON wire name. |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<Space> — an awaitable that resolves to Space.
Exceptions
| Type | Condition |
|---|---|
ArgumentNullException | request is null. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The 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)
HTTP — GET /v1/spaces/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The unique identifier of the space to retrieve |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<Space> — an awaitable that resolves to Space.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The 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)
HTTP — GET /v1/spaces
Parameters
| Type | Name | Description |
|---|---|---|
SpacesListOptions | options | Options bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional) |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
IAsyncEnumerable<Space> — an async stream; await foreach yields each Space across pages / events.
Exceptions
| Type | Condition |
|---|---|
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The 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)
HTTP — PUT /v1/spaces/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The unique identifier of the space to update |
UpdateSpaceRequest | request | The request payload; the linked model lists every field and its JSON wire name. |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task<Space> — an awaitable that resolves to Space.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
ArgumentNullException | request is null. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The 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)
HTTP — DELETE /v1/spaces/{id}
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The unique identifier of the space to delete |
CancellationToken | ct | Cancellation / deadline signal for the call. (optional) |
Returns
Task — completes when the operation finishes; there is no response body.
Exceptions
| Type | Condition |
|---|---|
ArgumentException | id is null or empty. |
NetworkException | The request could not reach the server (DNS, connection, or TLS failure). |
ApiException | The 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.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Name | string | name | The desired name for the space. Must be unique within the user's scope. |
Labels | IReadOnlyDictionary<string, string> | labels | A set of key-value pairs to categorize or tag the space. Used for filtering and organizational purposes. (optional) |
SpaceEmbedders | IReadOnlyList<SpaceEmbedderConfig> | spaceEmbedders | 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 | bool | publicRead | Indicates if the space and its memories can be read by unauthenticated users or users other than the owner. Defaults to false. (optional) |
OwnerId | string | ownerId | Optional owner ID. If not provided, derived from the authentication context. Requires CREATE_SPACE_ANY permission if specified. (optional) |
DefaultChunkingConfig | ChunkingConfiguration | defaultChunkingConfig | Default chunking strategy for memories in this space |
SpaceId | string | spaceId | Optional 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.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
EmbedderId | string | embedderId | The UUID for the embedder to associate with the space. |
DefaultRetrievalWeight | double | defaultRetrievalWeight | 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. (optional) |
Space
A Space is a container for organizing related memories with vector embeddings.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
SpaceId | string | spaceId | The UUID for this space. |
Name | string | name | The name of the space. |
Labels | IReadOnlyDictionary<string, string> | labels | Key-value pairs of metadata associated with the space. |
SpaceEmbedders | IReadOnlyList<SpaceEmbedder> | spaceEmbedders | The list of embedders associated with this space. |
CreatedAt | DateTimeOffset | createdAt | Timestamp when this space was created (milliseconds since epoch). |
UpdatedAt | DateTimeOffset | updatedAt | Timestamp when this space was last updated (milliseconds since epoch). |
OwnerId | string | ownerId | The ID of the user who owns this space. |
CreatedById | string | createdById | The ID of the user who created this space. |
UpdatedById | string | updatedById | The ID of the user who last updated this space. |
PublicRead | bool | publicRead | Whether this space is publicly readable by all users. |
DefaultChunkingConfig | ChunkingConfiguration | defaultChunkingConfig | Default chunking strategy for memories in this space (optional) |
SpaceEmbedder
Associates an embedder with a space, including retrieval configuration.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
SpaceId | string | spaceId | The UUID for the space. |
EmbedderId | string | embedderId | The UUID for the embedder. |
DefaultRetrievalWeight | double | defaultRetrievalWeight | The default weight for this embedder during retrieval operations. |
CreatedAt | DateTimeOffset | createdAt | Timestamp when this association was created (milliseconds since epoch). |
UpdatedAt | DateTimeOffset | updatedAt | Timestamp when this association was last updated (milliseconds since epoch). |
CreatedById | string | createdById | The ID of the user who created this association. |
UpdatedById | string | updatedById | The ID of the user who last updated this association. |
ListSpacesResponse
Response containing a list of spaces and optional pagination token.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Spaces | IReadOnlyList<Space> | spaces | The list of spaces matching the query criteria. |
NextToken | string | nextToken | Pagination token for retrieving the next set of results. Only present if there are more results available. (optional) |
UpdateSpaceRequest
Request parameters for updating a space.
| Property | Type | JSON (wire) | Description |
|---|---|---|---|
Name | string | name | The new name for the space. (optional) |
PublicRead | bool | publicRead | Whether the space is publicly readable by all users. (optional) |
ReplaceLabels | IReadOnlyDictionary<string, string> | replaceLabels | Labels to replace all existing labels. Mutually exclusive with mergeLabels. (optional) |
MergeLabels | IReadOnlyDictionary<string, string> | mergeLabels | Labels to merge with existing labels. Mutually exclusive with replaceLabels. (optional) |