Memory records
The long-term memory service provides APIs to create, query, update, and delete memory records. These operations are useful for importing historical memories, manually correcting records, and removing expired memories. Memories generated through automatic extraction can also be queried through these APIs. This topic explains how to manage memory records.
Prerequisites
You have enabled the wide table, search, vector, and AI engines, and completed the configuration required for the long-term memory service.
You have created a project and obtained a valid SK. For details, see project creation and access key setup.
Request details
Item | Description |
Request URL | The complete URL formed by combining the service endpoint and the API path. |
Authentication | Include the following authorization header: |
Project scope | Determined by the SK; you do not need to pass |
User scope | Determined by the user parameter of each API. The application is responsible for validating the user's identity. |
Request format | For JSON request bodies, set |
Response format | Successful responses contain |
Prepare connection information
Replace ENDPOINT with the service endpoint, including the protocol, hostname, and port. Replace SK with the project access key. Session, message, task, and memory IDs in the commands are examples; replace them with your own values.
ENDPOINT="<service endpoint>"
SK="<project SK>"Memory types
agent_memory is the query grouping for agent_case and agent_skill records. Supported query types are:
Types supported for queries:
event_log,episodic_memory,agent_memory,agent_case,agent_skillThe following types can be created manually and used as
parent_typevalues:event_log,episodic_memory,agent_case,agent_skill
Create a memory record
Create a memory record of the specified type.
Example request
curl --request POST "${ENDPOINT}/lmemo/v1/memory-records" \ --header "Authorization: Bearer ${SK}" \ --header "Content-Type: application/json" \ --data-raw '{ "kind": "event_log", "user_id": "u1", "content": "The user likes lattes.", "session_id": "session-001", "metadata": {} }'Parameters
Parameter
Type
Required
Description
kindstring
Yes
event_log,episodic_memory,agent_case,agent_skilluser_idstring
Yes
User ID
contentstring
Yes
Memory content; cannot be blank and can contain up to 8,192 characters.
metadataobject
No
Custom metadata
session_idstring
No
Associated session ID
mem_cell_idstring
No
Associated source-cell ID
parent_id,parent_typestring
No
Parent memory ID and type; for example, associate an
event_logwith anepisodic_memorysource_message_idsarray
No
Source message IDs
participantsarray
No
Participants
event_timestring
No
Event time in natural-language form
mentioned_atnumber
No
Timestamp (in milliseconds) of the message in which the event was mentioned
importancedouble
No
0–1
confidencedouble
No
0–1
Example response
The response data (
data) contains the complete record. For field descriptions, see Record response format.Supported optional parameters for each memory type:
Parameter
Supported memory types
session_id,mem_cell_id,source_message_idsevent_log,episodic_memory,agent_caseparent_id,parent_typeevent_logparticipantsevent_log,episodic_memoryevent_time,mentioned_atevent_logimportanceThis parameter is supported for all four writable memory types. For
agent_case, the value represents a quality score; foragent_skill, it represents a maturity score.confidenceevent_log,agent_skillWhen creating
agent_caseoragent_skill,metadatacontains the type-specific scores (quality_score,maturity_score,confidence) that take precedence over the corresponding top-level score parameters.NoteBefore manually creating memory records, make sure that the vectorization model has been configured.
List memory records
Query memory records with pagination and optional filters for user and memory type.
Example request
curl --request GET "${ENDPOINT}/lmemo/v1/memory-records?user_id=u1&kind=event_log&page=1&page_size=20" \ --header "Authorization: Bearer ${SK}"Parameters
Parameter
Description
user_idOptional; filters by user
kindOptional; one of the memory types supported for queries, including
agent_memory)pagePage number, starting at 1; defaults to 1
page_sizeNumber of records per page; range: 1–100; defaults to 20
Example response
{ "request_id": "req-example", "data": { "items": [], "pagination": { "page": 1, "page_size": 20, "total": 0, "has_more": false } } }NoteA list query can traverse up to the first 1,000 records for each memory type.
pagination.totalis an estimated count within the query scope.
Get, update, and delete a single memory record
Example request
# Get curl --request GET "${ENDPOINT}/lmemo/v1/memory-records/mem-001?user_id=u1" \ --header "Authorization: Bearer ${SK}" # Update curl --request PATCH "${ENDPOINT}/lmemo/v1/memory-records/mem-001?user_id=u1" \ --header "Authorization: Bearer ${SK}" \ --header "Content-Type: application/json" \ --data-raw '{ "content": "The user prefers unsweetened lattes.", "metadata": { "source": "manual" } }' # Delete curl --request DELETE "${ENDPOINT}/lmemo/v1/memory-records/mem-001?user_id=u1" \ --header "Authorization: Bearer ${SK}"When retrieving or updating a single record, you must pass
user_idas a query parameter. If a record does not exist or does not belong to the specified user, the API returns404 not_found; deleting a nonexistent record also returns 404. When deleting a record, explicitly passuser_idto limit the operation to the target user.Update request parameters
All fields are optional; only the fields included in the request are updated.
Field
Description
contentCannot be an empty string; maximum length is 8,192 characters
metadataMerges metadata by key. A key in the request overwrites the same key; omitted keys are retained.
categoriesDeduplicates category labels and replaces the existing list.
event_time,mentioned_atCorrects the time
participantsParticipants
importance,confidence0–1
metadata,categoriesandcontentare supported for all four writable memory types.metadatacontainsquality_score,maturity_scoreandconfidence; these take precedence over the corresponding top-level score parameters.event_time,mentioned_at,participants,importance,confidenceare applicable to the following memory types:Field
Applicable memory types
event_time,mentioned_atevent_logparticipantsevent_log,episodic_memoryimportanceevent_log,episodic_memory;agent_casemaps to a quality score,agent_skillmaps to a maturity score.confidenceevent_log,agent_skillExample response
{ "request_id": "req-xxx", "data": { "id": "mem-...", "deleted": true } }
Record response format
When you create, retrieve, or update a memory record, the response data contains the memory record object.
Example response
{
"request_id": "req-example",
"data": {
"id": "mem-...",
"user_id": "u1",
"content": "The user likes lattes.",
"kind": "event_log",
"metadata": {},
"created_at": "2026-07-24T08:00:00Z",
"updated_at": "2026-07-24T08:00:00Z",
"event_time": "2026-07-23",
"mentioned_at": "2026-07-24T08:00:00Z",
"session_id": "session-001",
"mem_cell_id": "cell-...",
"parent_type": "episodic_memory",
"parent_id": "mem-...",
"source_message_ids": ["msg-..."],
"participants": ["u1"]
}
}event_time, mentioned_at, session_id, mem_cell_id, parent_type, parent_id are returned only when they have values. To display the event time, use event_time and mentioned_at as the event time; created_at and updated_at indicate the storage time.