Memory records

Updated at:

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: Authorization: Bearer sk-...

Project scope

Determined by the SK; you do not need to pass project_id

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 Content-Type: application/json

Response format

Successful responses contain request_id and data. For error formats, see Service overview: Response handling.

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_skill

  • The following types can be created manually and used as parent_type values: 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

    kind

    string

    Yes

    event_log, episodic_memory, agent_case, agent_skill

    user_id

    string

    Yes

    User ID

    content

    string

    Yes

    Memory content; cannot be blank and can contain up to 8,192 characters.

    metadata

    object

    No

    Custom metadata

    session_id

    string

    No

    Associated session ID

    mem_cell_id

    string

    No

    Associated source-cell ID

    parent_id, parent_type

    string

    No

    Parent memory ID and type; for example, associate an event_log with an episodic_memory

    source_message_ids

    array

    No

    Source message IDs

    participants

    array

    No

    Participants

    event_time

    string

    No

    Event time in natural-language form

    mentioned_at

    number

    No

    Timestamp (in milliseconds) of the message in which the event was mentioned

    importance

    double

    No

    0–1

    confidence

    double

    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_ids

    event_log, episodic_memory, agent_case

    parent_id, parent_type

    event_log

    participants

    event_log, episodic_memory

    event_time, mentioned_at

    event_log

    importance

    This parameter is supported for all four writable memory types. For agent_case, the value represents a quality score; for agent_skill, it represents a maturity score.

    confidence

    event_log, agent_skill

    When creating agent_case or agent_skill, metadata contains the type-specific scores (quality_score, maturity_score, confidence) that take precedence over the corresponding top-level score parameters.

    Note

    Before 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_id

    Optional; filters by user

    kind

    Optional; one of the memory types supported for queries, including agent_memory)

    page

    Page number, starting at 1; defaults to 1

    page_size

    Number 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
        }
      }
    }
    Note

    A list query can traverse up to the first 1,000 records for each memory type. pagination.total is 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_id as a query parameter. If a record does not exist or does not belong to the specified user, the API returns 404 not_found; deleting a nonexistent record also returns 404. When deleting a record, explicitly pass user_id to 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

    content

    Cannot be an empty string; maximum length is 8,192 characters

    metadata

    Merges metadata by key. A key in the request overwrites the same key; omitted keys are retained.

    categories

    Deduplicates category labels and replaces the existing list.

    event_time, mentioned_at

    Corrects the time

    participants

    Participants

    importance, confidence

    0–1

    metadata, categories and content are supported for all four writable memory types. metadata contains quality_score, maturity_score and confidence; these take precedence over the corresponding top-level score parameters. event_time, mentioned_at, participants, importance, confidence are applicable to the following memory types:

    Field

    Applicable memory types

    event_time, mentioned_at

    event_log

    participants

    event_log, episodic_memory

    importance

    event_log, episodic_memory; agent_case maps to a quality score, agent_skill maps to a maturity score.

    confidence

    event_log, agent_skill

  • Example 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.