API Reference
Memories

Memories API

Memories are the core primitive in Cortex. Everything starts with storing memories, which Cortex then processes to extract beliefs, entities, and more.

Create a Memory

Store a new memory. Cortex automatically processes it to extract entities, beliefs, temporal information, and importance scores.

const memory = await cortex.memories.create({
  content: "Had a great meeting with Sarah about the Q4 roadmap. She wants to prioritize mobile.",
  source: "meeting_notes",
  metadata: {
    meeting_id: "mtg_123",
    attendees: ["sarah@example.com"]
  }
});

Parameters

ParameterTypeRequiredDescription
contentstringYesThe memory content (up to 32KB)
sourcestringNoOrigin of the memory (e.g., "email", "chat", "manual")
metadataobjectNoArbitrary JSON metadata
containerTagstringNoContainer for multi-tenant isolation

Response

{
  "id": "mem_abc123",
  "content": "Had a great meeting with Sarah...",
  "source": "meeting_notes",
  "metadata": {"meeting_id": "mtg_123"},
  "importanceScore": 0.75,
  "createdAt": "2024-01-15T10:30:00Z",
  "processing": {
    "status": "queued",
    "jobId": "job_xyz789"
  }
}

Search Memories

Search memories using hybrid search (semantic + keyword).

const results = await cortex.memories.search({
  query: "mobile roadmap",
  limit: 10,
  threshold: 0.5
});
 
for (const result of results.memories) {
  console.log(result.content, result.score);
}

Parameters

ParameterTypeDefaultDescription
querystringRequiredSearch query
limitnumber10Max results to return
thresholdnumber0.3Minimum similarity score (0-1)
sourcestring-Filter by source
containerTagstring-Filter by container

Response

{
  "memories": [
    {
      "id": "mem_abc123",
      "content": "Had a great meeting with Sarah...",
      "score": 0.89,
      "source": "meeting_notes",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 1,
  "searchId": "search_xyz"
}

Recall with Context

The most powerful endpoint. Returns relevant memories plus cognitive context (profile, beliefs, learnings).

const context = await cortex.recall({
  query: "What should we focus on for Q4?",
  includeProfile: true,
  includeBeliefs: true,
  includeLearnings: true,
  limit: 5
});
 
console.log(context.profile);     // User profile summary
console.log(context.memories);    // Relevant memories
console.log(context.beliefs);     // Related beliefs
console.log(context.learnings);   // Related learnings

Response

{
  "profile": "Senior product manager focused on mobile-first strategy...",
  "memories": [...],
  "beliefs": [
    {
      "id": "belief_123",
      "content": "User prioritizes mobile development",
      "confidence": 0.9
    }
  ],
  "learnings": [
    {
      "id": "learn_456",
      "content": "Q4 planning typically happens in September",
      "source": "pattern"
    }
  ],
  "entities": [
    {
      "id": "ent_789",
      "name": "Sarah",
      "type": "person",
      "relationship": "colleague"
    }
  ]
}

List Memories

Get all memories with pagination.

const page = await cortex.memories.list({
  limit: 20,
  offset: 0,
  source: "email"
});

Get a Memory

Retrieve a single memory by ID.

const memory = await cortex.memories.get("mem_abc123");

Delete a Memory

Soft-delete a memory. It's marked as forgotten but preserved for audit.

await cortex.memories.delete("mem_abc123");

Batch Operations

Create multiple memories at once for better performance.

const results = await cortex.memories.createBatch([
  { content: "First memory", source: "import" },
  { content: "Second memory", source: "import" },
  { content: "Third memory", source: "import" }
]);

Processing Status

Check the processing status of a memory.

const memory = await cortex.memories.get("mem_abc123");
 
if (memory.processingStatus === "done") {
  // Memory fully processed - entities, beliefs extracted
} else if (memory.processingStatus === "queued") {
  // Still being processed
} else if (memory.processingStatus === "failed") {
  // Processing failed - check processingError
}

Processing stages:

  1. queued - Waiting to be processed
  2. extracting - Extracting content and metadata
  3. chunking - Splitting into chunks if needed
  4. embedding - Creating vector embeddings
  5. indexing - Indexing in vector store
  6. done - Fully processed
  7. failed - Processing failed