Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

REST API

The REST API provides HTTP access to Mnemo, enabling non-MCP clients to interact with the memory database. Enable it with --rest-port:

mnemo --db-path my.db --rest-port 8080

All endpoints are under /v1/.

Configuration

  • CORS: controlled by MNEMO_CORS_ORIGINS environment variable. Defaults to localhost:3000 and localhost:8080. Set to * for permissive mode.
  • Body limit: 2 MB maximum request body.

Endpoints

Health Check

GET /v1/health

Returns {"status": "ok"}.

Remember

POST /v1/memories
Content-Type: application/json

{
  "content": "User prefers dark mode",
  "importance": 0.8,
  "tags": ["preferences"]
}

Returns {"id": "...", "content_hash": "..."}.

Recall

GET /v1/memories?query=preferences&limit=5&strategy=hybrid&min_importance=0.3

Query parameters:

ParameterTypeDescription
querystringNatural language search query (required)
agent_idstringFilter by agent
limitintegerMax results (default: 10, max: 100)
memory_typestringFilter: episodic, semantic, procedural, strategic
memory_typesstringComma-separated list of types
scopestringFilter: private, shared, global
min_importancefloatMinimum importance threshold
tagsstringComma-separated tag filter
org_idstringFilter by organization
strategystringhybrid, semantic, fulltext, exact, graph
as_ofstringPoint-in-time query (RFC 3339 timestamp)
hybrid_weightsstringComma-separated RRF weights
rrf_kfloatRRF constant (default: 60)

Get Memory by ID

GET /v1/memories/{id}

Forget

DELETE /v1/memories/{id}?strategy=soft_delete

Query parameters: strategy (soft_delete, hard_delete, decay, consolidate, archive), agent_id.

Share

POST /v1/memories/{id}/share
Content-Type: application/json

{
  "target_agent_id": "agent-2",
  "permission": "read",
  "expires_in_hours": 24
}

Checkpoint

POST /v1/checkpoints
Content-Type: application/json

{"label": "before-experiment"}

Branch

POST /v1/branches
Content-Type: application/json

{"checkpoint_id": "...", "branch_name": "experiment-1"}

Merge

POST /v1/merge
Content-Type: application/json

{"branch_name": "experiment-1"}

Replay

POST /v1/replay
Content-Type: application/json

{"checkpoint_id": "..."}

Verify

POST /v1/verify
Content-Type: application/json

{"agent_id": "my-agent"}

Delegate

POST /v1/delegate
Content-Type: application/json

{
  "agent_id": "my-agent",
  "delegate_id": "agent-2",
  "permission": "read",
  "memory_ids": ["uuid-1", "uuid-2"],
  "expires_in_hours": 48
}

The agent_id field identifies the caller. The server verifies the caller has Delegate permission on each memory in memory_ids before creating the delegation.

OTLP Ingest

POST /v1/ingest/otlp
Content-Type: application/json

{
  "resourceSpans": [...]
}

Accepts simplified OTLP JSON spans and converts them to agent events. Extracts GenAI semantic convention fields (gen_ai.request.model, gen_ai.usage.input_tokens, etc.).

Returns {"accepted": <count>}.

Error Handling

Errors return appropriate HTTP status codes with generic messages:

StatusMeaning
400Validation error (bad input)
403Permission denied
404Memory not found
500Internal error

Error body: {"error": "description"}. Internal errors are logged server-side; the response contains only a generic message to prevent information leakage.