Browse docs

API Reference

Tap to expand
APIUpdated 2026-05-25

Memory API

Write, search, update, and delete RetainDB memories over HTTP.

Applies to: RetainDB API v1

Memory routes are the low-level HTTP surface behind user and session memory.

Pick the right route

GoalRoute
Store one fact or preferencePOST /v1/memory
Store many known memoriesPOST /v1/memory/bulk
Search remembered user/session statePOST /v1/memory/search
Ingest a conversation transcriptPOST /v1/memory/ingest/session
Check async write statusGET /v1/memory/jobs/:jobId
Read memories for a user or sessionGET /v1/memory/profile/:userId, GET /v1/memory/session/:sessionId

Routes

  • POST /v1/memory
  • POST /v1/memory/bulk
  • POST /v1/memory/search
  • POST /v1/memory/ingest/session
  • GET /v1/memory/jobs/:jobId
  • GET /v1/memory/profile/:userId
  • GET /v1/memory/session/:sessionId
  • GET /v1/memory/:memoryId
  • PUT /v1/memory/:memoryId
  • DELETE /v1/memory/:memoryId

Write memory

bash
curl -X POST "https://api.retaindb.com/v1/memory" \
  -H "Authorization: Bearer $RETAINDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "app",
    "user_id": "user_123",
    "content": "User prefers concise answers.",
    "memory_type": "preference",
    "write_mode": "async"
  }'

Typical accepted response:

json
{
  "success": true,
  "mode": "async",
  "trace_id": "trc_..."
}

Search memory

bash
curl -X POST "https://api.retaindb.com/v1/memory/search" \
  -H "Authorization: Bearer $RETAINDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "app",
    "user_id": "user_123",
    "query": "How should I reply?",
    "include_pending": true,
    "top_k": 5
  }'

Typical search response:

json
{
  "results": [
    {
      "memory": {
        "id": "mem_...",
        "content": "User prefers concise answers.",
        "memory_type": "preference"
      },
      "score": 0.82
    }
  ],
  "count": 1,
  "trace_id": "trc_..."
}

Defaults

  • Use write_mode: "async" unless you need synchronous confirmation.
  • Use include_pending: true immediately after recent writes.
  • Keep scope identifiers stable.
  • Prefer small, high-signal memories over raw full transcripts.

Common mistakes

SymptomLikely causeFix
Empty search after writeDifferent project or user_idReuse the exact same identifiers
Fresh write not visibleAsync write still processingSearch with pending visibility or retry
Good memory for wrong userCaller scope is not enforced server-sideAttach scope after your own auth check
Slow promptsSending too much memory to the modelLower top_k or use the SDK formatted context

Next: Raw HTTP quickstart.

Was this page helpful?

Your feedback helps us prioritize docs improvements weekly.