Skip to main content

Memory Space Domain API

Space records and participant lists are data; trusted principal/membership/grant records establish runtime access. Space erasure uses supported-layer receipts and current scope. A runtime scope selector never creates a grant.

Usage boundary​

Access the namespace on an explicitly configured root Cortex client. Host JWT and deployment-operator transports are distinct; validate current resource scope and do not infer authority from AuthContext metadata. See administrative operations.

Register, inspect and remove a space​

register requires memorySpaceId and accepts name, type (personal/team/project/custom), participants and metadata. get returns the registration or null. Registration/participant metadata does not grant runtime access: trusted current grants are separate. list supports type/tenant/limit filters and returns spaces, total and pagination metadata; getStats reports memory/conversation/fact/message counts and optional time-window/participant statistics.

Storage statistics use storageMeasurement: "convex-json-utf8-estimate": a serialized full-document estimate excluding files, indexes and physical storage overhead. Do not present it as billed physical storage. update changes registration metadata/participants with the supported options.

import type { Cortex } from '@cortexmemory/sdk';

export async function inspectApprovedSpace(cortex: Cortex, memorySpaceId: string) {
const space = await cortex.memorySpaces.get(memorySpaceId);
if (!space) return null;
const stats = await cortex.memorySpaces.getStats(memorySpaceId);
return { name: space.name, memories: stats.totalMemories,
estimatedBytes: stats.storage.totalBytes, measurement: stats.storageMeasurement };
}

delete requires cascade: true and an audit reason, with optional confirmId matching the space. Cascades use supported ownership/readiness checks and administrative erasure transport; dryRun/verification/graph participation semantics are the same bounded erasure model described in user operations. Inspect erasure receipts and retained/shared outcomes. This explicit registry API is separate from administrator revocation/tombstoning of a managed runtime scope.

Parameter and result contracts​

These are reference definitions for the explicit server APIs. Optional fields use ?; timestamps are milliseconds since epoch unless an operation accepts a Date. Resource identifiers and participant metadata do not grant runtime authority.

RegisterMemorySpaceParams​

export interface RegisterMemorySpaceParams {
memorySpaceId: string;
tenantId?: string;
name?: string;
type: "personal" | "team" | "project" | "custom";
participants?: Array<{
id: string;
type: string;
}>;
metadata?: Record<string, unknown>;
}

MemorySpace​

export interface MemorySpace extends GraphCaptureMetadata {
_id: string;
memorySpaceId: string;
tenantId?: string;
name?: string;
type: "personal" | "team" | "project" | "custom";
participants: Array<{
id: string;
type: string;
joinedAt: number;
}>;
metadata: Record<string, unknown>;
status: "active" | "archived";
createdAt: number;
updatedAt: number;
}

Also inherits GraphCaptureMetadata. See shared contracts.

ListMemorySpacesFilter​

export interface ListMemorySpacesFilter {
type?: "personal" | "team" | "project" | "custom";
status?: "active" | "archived";
tenantId?: string;
participant?: string;
limit?: number;
offset?: number;
sortBy?: "createdAt" | "updatedAt" | "name";
sortOrder?: "asc" | "desc";
}

ListMemorySpacesResult​

export interface ListMemorySpacesResult {
spaces: MemorySpace[];
total: number;
hasMore: boolean;
offset: number;
}

UpdateMemorySpaceOptions​

export interface UpdateMemorySpaceOptions extends GraphSyncOption {}

Also inherits GraphSyncOption. See shared contracts.

GetMemorySpaceStatsOptions​

export interface GetMemorySpaceStatsOptions {
tenantId?: string;
timeWindow?: "24h" | "7d" | "30d" | "90d" | "all";
includeParticipants?: boolean;
}

MemorySpaceStats​

export interface MemorySpaceStats {
storageMeasurement?: "convex-json-utf8-estimate";
memorySpaceId: string;
totalMemories: number;
totalConversations: number;
totalFacts: number;
totalMessages: number;
storage: {
conversationsBytes: number;
memoriesBytes: number;
factsBytes: number;
totalBytes: number;
};
avgSearchTime?: string;
topTags: string[];
importanceBreakdown: {
critical: number;
high: number;
medium: number;
low: number;
trivial: number;
};
participants?: Array<{
participantId: string;
memoriesStored: number;
conversationsStored: number;
factsExtracted: number;
firstActive: number;
lastActive: number;
avgImportance: number;
topTags: string[];
}>;
memoriesThisWindow?: number;
conversationsThisWindow?: number;
}
FieldMeaning and defaults
storageMeasurementSerialized full-document estimate; excludes files, indexes and physical storage overhead.

DeleteMemorySpaceOptions​

export interface DeleteMemorySpaceOptions extends GraphSyncOption, ErasureOptions {
cascade: boolean;
reason: string;
confirmId?: string;
}

Also inherits GraphSyncOption, ErasureOptions. See erasure options.

DeleteMemorySpaceResult​

export interface DeleteMemorySpaceResult {
memorySpaceId: string;
deleted: boolean;
totalBytesKind?: "serializedDocumentEstimate";
erasure?: import("../users/erasure").ErasureReceipt;
cascade: {
conversationsDeleted: number;
memoriesDeleted: number;
factsDeleted: number;
totalBytes: number;
};
reason: string;
deletedAt: number;
}

Public methods​

The following signatures describe the TypeScript namespace. Parameter and result fields are defined on this page; the installed @cortexmemory/sdk declarations also provide their compile-time types. Signatures are reference notation, not application code to execute.

createErasureTransport​

cortex.memorySpaces.createErasureTransport(options:Parameters<typeof createErasureTransport>[0]): ErasureTransport

register​

Register a new memory space

cortex.memorySpaces.register(params: RegisterMemorySpaceParams, _options?: RegisterMemorySpaceOptions): Promise<MemorySpace>

get​

Get memory space by ID

cortex.memorySpaces.get(memorySpaceId: string): Promise<MemorySpace | null>

list​

List memory spaces with pagination and sorting

cortex.memorySpaces.list(filter?: ListMemorySpacesFilter): Promise<ListMemorySpacesResult>

count​

Count memory spaces

cortex.memorySpaces.count(filter?: { type?: "personal" | "team" | "project" | "custom"; status?: "active" | "archived"; }): Promise<number>

update​

Update memory space metadata

cortex.memorySpaces.update(memorySpaceId: string, updates: { name?: string; metadata?: Record<string, unknown>; status?: "active" | "archived"; }, _options?: UpdateMemorySpaceOptions): Promise<MemorySpace>

addParticipant​

Add participant to memory space

cortex.memorySpaces.addParticipant(memorySpaceId: string, participant: { id: string; type: string; joinedAt: number; }): Promise<MemorySpace>

removeParticipant​

Remove participant from memory space

cortex.memorySpaces.removeParticipant(memorySpaceId: string, participantId: string): Promise<MemorySpace>

archive​

Archive memory space (marks as inactive but preserves data)

cortex.memorySpaces.archive(memorySpaceId: string, options?: { reason?: string; metadata?: Record<string, unknown>; }): Promise<MemorySpace>

reactivate​

Reactivate archived memory space

cortex.memorySpaces.reactivate(memorySpaceId: string): Promise<MemorySpace>

delete​

Delete a memory space and its supported exclusive primary data.

cortex.memorySpaces.delete(memorySpaceId: string, options: DeleteMemorySpaceOptions): Promise<DeleteMemorySpaceResult>

getStats​

Get memory space statistics with optional time window and participant breakdown

cortex.memorySpaces.getStats(memorySpaceId: string, options?: GetMemorySpaceStatsOptions): Promise<MemorySpaceStats>

findByParticipant​

Find memory spaces by participant

cortex.memorySpaces.findByParticipant(participantId: string): Promise<MemorySpace[]>

Search memory spaces by name or metadata

cortex.memorySpaces.search(query: string, options?: { type?: "personal" | "team" | "project" | "custom"; status?: "active" | "archived"; limit?: number; }): Promise<MemorySpace[]>

updateParticipants​

Update participants (combined add/remove)

cortex.memorySpaces.updateParticipants(memorySpaceId: string, updates: { add?: Array<{ id: string; type: string; joinedAt: number }>; remove?: string[]; }): Promise<MemorySpace>

Errors and lifecycle​

Validation, missing capability, authorization, stale version and partial/unknown committed outcomes are explicit. Inspect operation/write/deletion receipts before recovery; do not repeat an external effect under a new identity after uncertainty. Close owned clients and graph resources at the end of the server workflow.

See runtime client for ordinary app execution and error handling for recovery boundaries.