Quickstart: API
This guide walks through the four core operations using curl.
Prerequisites
Section titled “Prerequisites”- Installation completed
- API token ready (
mlk_...)
Step 1: Store a memory (retain)
Section titled “Step 1: Store a memory (retain)”curl -X POST https://api.memlayer.dev/api/v1/retain \ -H "Content-Type: application/json" \ -H "X-API-Key: mlk_your_api_key_here" \ -d '{"content": "User prefers Haskell for type-safe programming"}'Example response:
{ "operations": [ { "type": "create", "memory_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "content": "User prefers Haskell for type-safe programming", "reason": "New fact about user programming language preference" } ], "summary_triggered": false}The retain pipeline extracts entities from the input, decides whether to create or update, generates a vector embedding, and stores everything in the bitemporal database and vector index.
Step 2: Search memories (recall)
Section titled “Step 2: Search memories (recall)”curl -H "X-API-Key: mlk_your_api_key_here" \ "https://api.memlayer.dev/api/v1/recall?query=programming+language&limit=5"Example response:
{ "memories": [ { "memory": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "entity_id": "user-haskell-preference", "content": "User prefers Haskell for type-safe programming", "layer": 2, "importance": 0.75, "valid_from": "2025-01-15T10:30:00Z", "valid_to": null }, "similarity_score": 0.92 } ]}Recall converts the query into a vector embedding and performs a semantic search. Results are ranked by similarity and re-ranked using temporal signals.
Step 3: Consolidate memories (reflect)
Section titled “Step 3: Consolidate memories (reflect)”curl -X POST https://api.memlayer.dev/api/v1/reflect \ -H "Content-Type: application/json" \ -H "X-API-Key: mlk_your_api_key_here" \ -d '{}'Reflect scans your stored memories and groups related facts into higher-level concepts and domains.
Step 4: Forget an entity
Section titled “Step 4: Forget an entity”Use the entity_id from a recall response to remove a specific memory:
curl -X POST https://api.memlayer.dev/api/v1/forget \ -H "Content-Type: application/json" \ -H "X-API-Key: mlk_your_api_key_here" \ -d '{"entity_id": "user-haskell-preference"}'Forget removes the entity from active queries and deletes its embeddings. The bitemporal database retains the historical record for audit purposes, but the memory will no longer appear in recall results.
Next steps
Section titled “Next steps”- Concepts — understand semantic layers, bitemporality, and the knowledge graph
- API Reference — full endpoint documentation with request/response schemas
- MCP Integration — use MemLayer as a tool in Claude Desktop or Claude Code