Skip to content

Quickstart: API

This guide walks through the four core operations using curl.

Terminal window
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.

Terminal window
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.

Terminal window
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.

Use the entity_id from a recall response to remove a specific memory:

Terminal window
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.

  • 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