Memory
The memory API manages knowledge chunks extracted from Claude Code sessions. Each chunk has a type, relevance score, and optional project association. For conceptual details, see Claude Memory System.
Endpoints
Search Memories
GET /api/memory/search
Search stored memory chunks by text query with optional filters. Matching memories have their access count incremented automatically.
Authentication: Required
Query Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
query | string | No | Text to search in content and sourceExcerpt (ILIKE) |
projectPath | string | No | Filter by project path |
chunkType | string | No | Filter by type: decision, fact, solution, pattern, preference, summary |
minRelevance | number | No | Minimum relevance score (0-1) |
limit | number | No | Max results (default 20, max 100) |
Response: 200 OK
{
"data": [
{
"id": "uuid",
"sessionId": "session-abc",
"projectPath": "/home/user/my-project",
"chunkType": "decision",
"content": "Use PostgreSQL for the database layer",
"sourceExcerpt": "After evaluating SQLite and Postgres...",
"relevanceScore": 0.95,
"accessCount": 3,
"lastAccessedAt": "2026-02-18T12:00:00.000Z",
"createdAt": "2026-02-15T08:30:00.000Z"
}
]
}
Get Context
GET /api/memory/context
Retrieve recent, high-relevance memories formatted for Claude context injection. Returns both raw memory objects and a pre-formatted text block grouped by type.
Authentication: Required
Query Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
project | string | No | Filter by project path |
limit | number | No | Max memories (default 5, max 20) |
Response: 200 OK
{
"data": {
"memories": [{ "id": "uuid", "chunkType": "decision", "content": "..." }],
"formatted": "5 memories loaded:\n\n### Decisions\n- Use PostgreSQL\n\n### Patterns\n- Always use pnpm\n"
}
}
The formatted string is designed for direct injection into Claude's system prompt. The Claude hooks call this endpoint at session start.
Store Memory
POST /api/memory/store
Store a single memory chunk. Broadcasts a resource_change notification on success.
Authentication: Required
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The memory text |
chunkType | string | Yes | One of: decision, fact, solution, pattern, preference, summary |
sessionId | string | No | Claude session ID |
projectPath | string | No | Associated project path |
sourceExcerpt | string | No | Original conversation excerpt |
relevanceScore | number | No | 0-1 score (default 1.0) |
Response: 201 Created
{
"data": {
"id": "uuid",
"chunkType": "fact",
"content": "The deploy target is a Hetzner VPS running Ubuntu 24.04",
"relevanceScore": 1.0,
"accessCount": 0,
"createdAt": "2026-02-18T12:00:00.000Z"
}
}
Extract Memories
POST /api/memory/extract
Extract and store memories from a conversation transcript using AI. Accepts either raw transcript text or a file path to a transcript.
Authentication: Required
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
transcript | string | Conditional | Raw conversation text (required if no transcriptPath) |
transcriptPath | string | Conditional | Path to transcript file (required if no transcript) |
sessionId | string | No | Claude session ID |
projectPath | string | No | Associated project path |
Response: 200 OK
{
"data": [
{ "id": "uuid", "chunkType": "decision", "content": "Use Drizzle ORM", "relevanceScore": 0.9 }
],
"message": "Extracted 3 memories"
}
If no extractable memories are found:
{
"data": [],
"message": "No memories worth extracting"
}
Delete Memory
DELETE /api/memory/:id
Delete a single memory chunk by ID. Broadcasts a resource_change notification.
Authentication: Required
Path Parameters:
| Param | Type | Description |
|---|---|---|
id | string (UUID) | Memory chunk ID |
Response: 200 OK
{ "data": { "success": true } }
Errors:
| Status | Condition |
|---|---|
400 | Missing ID |
404 | Memory not found |
Type Reference
Memory types are defined in shared/types/index.ts. See Database Schema for the full memory_chunks table definition.
| Type | Description |
|---|---|
decision | Architectural or design decisions |
fact | Key facts about the environment or project |
solution | Solutions to problems encountered |
pattern | Recurring patterns or conventions |
preference | User preferences and style choices |
summary | Conversation or session summaries |