Memory API
Structured user memory management with categories, search, statistics, and batch operations. Routes are mounted at /api/memory (src/services/routes/memoryRoutes.js).
Get User List
GET /api/memory/usersResponse
{
"success": true,
"data": [
{ "userId": "123456", "memoryCount": 15 }
]
}Get Memory Statistics
GET /api/memory/statsResponse
{
"success": true,
"data": {
"totalMemories": 120,
"totalUsers": 8,
"categories": {
"profile": "Basic Information",
"preference": "Preferences and Habits",
"event": "Important Events",
"relation": "Relationships",
"topic": "Topic Interests",
"custom": "Custom"
}
}
}Get Category Definitions
GET /api/memory/categoriesGet a User's Memories
GET /api/memory/user/:userIdQuery Parameters
| Parameter | Type | Description |
|---|---|---|
| format | string | tree (tree structure, default) or list |
| groupId | string | Restrict to a group |
| category | string | Filter by category |
| limit | number | Number of entries to return |
Search Memories
POST /api/memory/searchRequest Body
| Parameter | Type | Description |
|---|---|---|
| query | string | Search keyword (required) |
| userId | string | Restrict to a user |
| groupId | string | Restrict to a group |
| category | string | Restrict to a category |
| limit | number | Number of entries (default 20) |
Add a Memory
POST /api/memory/user/:userIdRequest Body
{
"content": "The user is a software engineer",
"category": "profile"
}Update a Memory
PUT /api/memory/:idDelete a Memory
DELETE /api/memory/:idThe hard query parameter accepts 'true' / '1' (query parameters are always strings; the bug where the old === 'true' check was always false has been fixed).
Clear a User's Memories
DELETE /api/memory/user/:userIdThe hard query parameter has the same semantics as above.
Summarize Memories
POST /api/memory/user/:userId/summarizeRuns an AI summary to merge the user's memories and reduce redundant entries. Summary results use structured lines in the form [category] content (category whitelist: profile / preference / event / relation / topic / custom); reasoning text output by the model is not stored.
Request Body
{
"useLLM": true,
"cleanup": true
}| Parameter | Type | Default | Description |
|---|---|---|---|
useLLM | boolean | true | Whether to use an LLM for the summary |
cleanup | boolean | true | Whether to run low-quality memory cleanup after summarizing (skipped when cleanup === false / 'false') |
groupId | string | - | Restrict to a group |
model | string | - | Specify the summary model |
Clean Up Low-Quality Memories
POST /api/memory/user/:userId/cleanupCleans up the user's low-quality memories (low confidence / expired / too old / too short) without an LLM call.