API Reference

MemDB REST API for storing, searching, and managing agent memories. All endpoints require Bearer token authentication.

https://api.memdb.ai

Authentication

All requests (except GET /health) require a Bearer token in the Authorization header.

Authorization: Bearer YOUR_API_KEY
curl https://api.memdb.ai/health

curl https://api.memdb.ai/product/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id":"agent-1","query":"preferences"}'

Endpoints

Health Check

GET /health

No authentication required. Returns service status, Go version, and hostname.

Response

{"code":200,"status":"healthy","go_version":"go1.26","hostname":"memdb-go","service":"memdb-go"}

Add Memories

POST /product/add

Store new memories from conversations or raw text. MemDB extracts entities, classifies memory types, deduplicates, and persists asynchronously by default.

Request Body

FieldTypeDescription
user_idstringUser/agent identifier
messages*arrayMessages: [{"role":"user","content":"..."}]
custom_tagsstring[]Tags for filtering: ["preference","style"]
async_modestring"async" (default) or "sync"
modestring"raw" (store as-is) or "fast" (LLM extraction). Sync only.
session_idstringGroup memories by session
infoobjectMetadata: {"agent_id":"...", "source_type":"web"}

Example

curl -X POST https://api.memdb.ai/product/add \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id":"agent-123","messages":[{"role":"user","content":"I prefer bullet points"}],"custom_tags":["preference"]}'

Delete Memories

POST /product/delete_memory

Delete specific memories by ID, or all memories for a user. Instant — no reindex needed.

Request Body

FieldTypeDescription
user_id*stringUser/agent identifier
memory_idsstring[]IDs to delete: ["mem_abc","mem_def"]
delete_allboolDelete all memories for this user

Example

curl -X POST https://api.memdb.ai/product/delete_memory \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id":"agent-123","memory_ids":["mem_abc123","mem_def456"]}'

Get All Memories

POST /product/get_all

Retrieve all memories for a user with pagination. 70× faster than the Python baseline.

Request Body

FieldTypeDescription
user_id*stringUser/agent identifier
pageintPage number (default: 1)
page_sizeintResults per page (default: 20)

Get Memories

POST /product/get_memory

Retrieve memories matching specific criteria.

Request Body

FieldTypeDescription
user_id*stringUser/agent identifier
filterobjectStructured filter

Get Memory by ID

GET /product/get_memory/{memory_id}

Retrieve a single memory by its ID.

Chat Complete

POST /product/chat/complete

Memory-augmented chat completion. Searches relevant memories and injects them into LLM context.

Request Body

FieldTypeDescription
user_id*stringUser/agent identifier
messages*arrayChat messages: [{"role":"user","content":"..."}]
system_promptstringSystem prompt override
add_message_on_answerboolStore exchange after completion (default: false)

Chat Stream

POST /product/chat/stream

Same as Chat Complete but returns SSE stream for real-time UIs.

Feedback

POST /product/feedback

Submit feedback on a memory to improve future search ranking.

Request Body

FieldTypeDescription
user_id*stringUser/agent identifier
memory_id*stringMemory to rate
feedbackstring"positive" or "negative"