Skip to main content

Memories

Store and retrieve memories for AI agents.

POST /api/v1/memories

Create a memory (single or batch).

Single Memory

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_web_crawler",
"session_id": "sess_abc123",
"memory_type": "episodic",
"event_type": "page_crawled",
"content": "Crawled https://example.com — found 3 product pages",
"metadata": {"url": "https://example.com", "pages_found": 3},
"tags": ["crawling", "products"],
"importance": 0.7,
"dedup_key": "crawl_example_2026-02-07"
}'

Batch Memories

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"memories": [
{"agent_id": "agent_1", "content": "First memory", "memory_type": "episodic"},
{"agent_id": "agent_1", "content": "Second memory", "memory_type": "decision"}
]
}'

Request Fields

FieldTypeRequiredDefaultDescription
agent_idstringyesAgent identifier
contentstringyesMemory content
memory_typestringnoepisodicepisodic, session, decision, entity
event_typestringnogeneralApp-defined event type
session_idstringnoSession scope
metadataobjectnoArbitrary key-value data
tagsstring[]noTags for filtering
importancefloatno00.0 to 1.0
dedup_keystringnoautoDeduplication key
parent_idstringnoParent memory for threading

Memory Types

  • episodic: What happened (actions, observations)
  • decision: Why something happened (reasoning, choices)
  • entity: What exists (entities, facts, relationships)
  • session: Session-specific context

Response

Status: 201 Created

{
"time": "2026-02-07T20:15:00Z",
"org_id": "org_default",
"agent_id": "agent_web_crawler",
"content": "Crawled https://example.com — found 3 product pages",
"memory_type": "episodic",
"event_type": "page_crawled",
"dedup_key": "a1b2c3d4..."
}

GET /api/v1/memories

List memories with filters.

Query Parameters

ParamTypeDescription
agent_idstringFilter by agent
session_idstringFilter by session
memory_typestringFilter by type
event_typestringFilter by event type
tagsstringComma-separated tags (AND)
sincestringRelative (2h, 7d) or ISO8601
untilstringRelative or ISO8601
limitintMax results (default 100, max 1000)
offsetintPagination offset
orderstringasc or desc (default)

Examples

Recent memories for an agent:

curl "http://localhost:9100/api/v1/memories?agent_id=my_agent&since=2h" \
-H "x-api-key: mtk_..."

Memories for a session:

curl "http://localhost:9100/api/v1/memories?session_id=sess_abc&since=4h" \
-H "x-api-key: mtk_..."

Filter by type and tags:

curl "http://localhost:9100/api/v1/memories?agent_id=my_agent&memory_type=episodic&tags=crawling,products&since=7d" \
-H "x-api-key: mtk_..."

Time range:

curl "http://localhost:9100/api/v1/memories?agent_id=my_agent&since=2026-02-01T00:00:00Z&until=2026-02-07T23:59:59Z" \
-H "x-api-key: mtk_..."

Pagination:

curl "http://localhost:9100/api/v1/memories?agent_id=my_agent&limit=50&offset=100" \
-H "x-api-key: mtk_..."

Response

{
"memories": [
{
"time": "2026-02-13T10:30:00Z",
"agent_id": "my_agent",
"session_id": "sess_abc",
"memory_type": "episodic",
"event_type": "page_crawled",
"content": "Crawled https://example.com",
"metadata": {"url": "https://example.com"},
"tags": ["crawling"],
"importance": 0.7
}
],
"count": 42,
"has_more": true
}

GET /api/v1/memories/:id

Get a specific memory by ID.

Request

curl "http://localhost:9100/api/v1/memories/abc123" \
-H "x-api-key: mtk_..."

Response

{
"time": "2026-02-13T10:30:00Z",
"memory_id": "abc123",
"agent_id": "my_agent",
"content": "Crawled https://example.com",
"memory_type": "episodic",
"event_type": "page_crawled",
"metadata": {"url": "https://example.com"},
"tags": ["crawling"],
"importance": 0.7
}

Examples

Store an episodic memory

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_researcher",
"content": "Read article: Go generics best practices",
"memory_type": "episodic",
"event_type": "article_read",
"tags": ["research", "golang"],
"importance": 0.8
}'

Store a decision memory

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_writer",
"content": "Decided to write about Go generics because engagement was high last week",
"memory_type": "decision",
"event_type": "topic_selected",
"tags": ["content"],
"importance": 0.9
}'

Store an entity memory

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_crm",
"content": "Customer prefers email communication, timezone PST",
"memory_type": "entity",
"event_type": "customer_preference",
"metadata": {"customer_id": "cust_123"},
"tags": ["customer", "preferences"],
"importance": 0.7
}'

Batch insert

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"memories": [
{
"agent_id": "agent_pipeline",
"content": "Processed batch 1: 1000 records",
"memory_type": "episodic",
"event_type": "batch_processed"
},
{
"agent_id": "agent_pipeline",
"content": "Processed batch 2: 1000 records",
"memory_type": "episodic",
"event_type": "batch_processed"
},
{
"agent_id": "agent_pipeline",
"content": "Processed batch 3: 1000 records",
"memory_type": "episodic",
"event_type": "batch_processed"
}
]
}'

Deduplication

Use dedup_key to prevent duplicate memories:

curl -X POST http://localhost:9100/api/v1/memories \
-H "x-api-key: mtk_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_crawler",
"content": "Crawled https://example.com",
"memory_type": "episodic",
"dedup_key": "crawl_example_2026-02-13"
}'

If another memory with the same dedup_key exists within the deduplication window (default 24 hours), the second memory will be rejected.