Skip to content

Memories

Ingest content into the knowledge graph.

Terminal window
curl -X POST https://api.memlayer.dev/api/v1/retain \
-H "Content-Type: application/json" \
-d '{"content": "User prefers Haskell for type-safe programming", "source": "conversation"}'

Request:

FieldTypeRequiredDescription
contentstringYesContent to process and extract memories from
sourcestringNoOrigin identifier
systemstringNoSystem context for LLM
valid_timeISO 8601NoWhen this fact was true (defaults to now)

Response:

{
"operations": [
{
"type": "create",
"memory_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"content": "User prefers Haskell for type-safe programming",
"reason": "New fact about programming preference"
}
],
"summary_triggered": false,
"usage": {
"extraction": {"prompt_tokens": 150, "completion_tokens": 50, "total_tokens": 200},
"decision": {"prompt_tokens": 200, "completion_tokens": 30, "total_tokens": 230},
"total_tokens": 430
}
}

Semantic search for memories.

Terminal window
curl "https://api.memlayer.dev/api/v1/recall?query=programming+language&limit=5&expand_graph=true"

Query Parameters:

ParameterTypeRequiredDescription
querystringYesNatural language search
limitintNoMax results (default: 5)
layerint (0-3)NoFilter by semantic layer
as_ofISO 8601NoTemporal query point
expand_graphboolNoInclude relationships and ancestors

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,
"relationships": [],
"ancestors": []
}
],
"usage": {"prompt_tokens": 50, "completion_tokens": 0, "total_tokens": 50}
}

Consolidate and organize memories.

Terminal window
curl -X POST https://api.memlayer.dev/api/v1/reflect \
-H "Content-Type: application/json" \
-d '{"query": "programming", "dry_run": false}'

Request:

FieldTypeRequiredDefaultDescription
querystringNoTopic filter
dry_runboolNofalsePreview without applying
thresholdfloatNo0.7Linking threshold
cluster_thresholdfloatNo0.8Clustering threshold
limitintNo100Max facts to process

Delete an entity and all its data from active queries.

Terminal window
curl -X POST https://api.memlayer.dev/api/v1/forget \
-H "Content-Type: application/json" \
-d '{"entity_id": "user-haskell-preference"}'

Response:

{
"entity_id": "user-haskell-preference",
"memories_removed": 1,
"relationships_removed": 2
}

Bulk memory ingestion without LLM processing.

Terminal window
curl -X POST https://api.memlayer.dev/api/v1/ingest \
-H "Content-Type: application/json" \
-d '{
"memories": [
{"content": "Alice is a software engineer", "source": "import"},
{"content": "Alice lives in Berlin", "source": "import"}
],
"entity_id": "alice-profile"
}'

Response:

{"processed": 2, "failed": 0, "results": [{"success": true, "memory_id": "uuid-1"}, {"success": true, "memory_id": "uuid-2"}]}

List memories with optional filters.

Terminal window
curl "https://api.memlayer.dev/api/v1/memories?entity_id=alice-profile&layer=2&limit=20"
ParameterTypeDescription
entity_idstringFilter by entity
layerstringFilter by layer
limitintMax results

Get a single memory by UUID. Returns 404 if not found.

Terminal window
curl https://api.memlayer.dev/api/v1/memories/a1b2c3d4-e5f6-7890-abcd-ef1234567890

Delete a single memory. Returns 204 No Content.

Terminal window
curl -X DELETE https://api.memlayer.dev/api/v1/memories/a1b2c3d4-e5f6-7890-abcd-ef1234567890

Get child memories in the layer hierarchy.

Terminal window
curl https://api.memlayer.dev/api/v1/memories/a1b2c3d4-e5f6-7890-abcd-ef1234567890/children

Get all relationships where this memory is source or target.

Terminal window
curl https://api.memlayer.dev/api/v1/memories/a1b2c3d4-e5f6-7890-abcd-ef1234567890/relationships

Traverse to a specific layer from a given memory.

Terminal window
curl https://api.memlayer.dev/api/v1/memories/a1b2c3d4-e5f6-7890-abcd-ef1234567890/layer/0

Returns ancestors or descendants at the requested layer.