Skip to Content
REST APIEndpointsMemories

Memories Endpoints

Memories are the core data units in zkstash. These endpoints allow you to store, retrieve, and manage the long-term memory of your agents.

Create Memory

Extracts and stores new memories from a conversation. The system automatically processes the conversation using your registered schemas to create structured memories.

Endpoint: POST /memories

Request Body

FieldTypeRequiredDescription
agentIdstringYesUnique identifier for the agent.
conversationarrayYesList of message objects representing the interaction.
threadIdstringNoIdentifier for the conversation thread.
schemasstring[]NoList of schema names to use for extraction. If omitted, uses all registered schemas.

Conversation Object:

{ "role": "user" | "assistant" | "system", "content": "string" }

Example Request

{ "agentId": "agent-007", "conversation": [ { "role": "user", "content": "My favorite color is blue." }, { "role": "assistant", "content": "Noted." } ] }

Response

Returns the created and updated memories.

{ "success": true, "created": [ { "kind": "UserProfile", "metadata": { "favoriteColor": "blue" } } ], "updated": [] }

Search Memories

Search for memories using semantic similarity and metadata filters.

Endpoint: GET /memories/search

Query Parameters

ParameterTypeRequiredDescription
querystringYesThe natural language query to search for (e.g., “user preferences”).
agentIdstringNoFilter by agent ID.
threadIdstringNoFilter by specific thread ID.
kindstringNoFilter by memory schema type (e.g., UserProfile).
tagsstringNoComma-separated list of tags to filter by.
limitnumberNoMax number of results (default: 10).
modestringNoResponse format: raw (default), answer (QA), or map (Graph).

Example Request

GET /memories/search?query=What+does+he+like?&agentId=agent-007&limit=5

Response

{ "success": true, "memories": [ { "id": "mem_123...", "kind": "UserProfile", "score": 0.89, "data": { "favoriteColor": "blue" }, "metadata": { "agentId": "agent-007", "timestamp": 1700000000 } } ] }

Get Memory

Retrieve a single memory by its ID.

Endpoint: GET /memories/[id]

Parameters

ParameterTypeRequiredDescription
idstringYesThe unique ID of the memory.

Response

{ "success": true, "memory": { "id": "mem_123...", "kind": "UserProfile", "data": { ... } } }

Update Memory

Update a memory’s metadata or extend its retention lease.

Endpoint: PATCH /memories/[id]

Request Body

FieldTypeRequiredDescription
tagsstring[]NoNew list of tags for the memory.
extendLeasebooleanNoIf true, resets the memory’s retention period (e.g., extends TTL by 7 days for free plans).

Example Request

{ "tags": ["important", "verified"], "extendLease": true }

Response

{ "success": true, "memory": { ... } }
Last updated on