The Memory Storage Service offers 13 APIs via the HTTP JSON protocol, covering memory store management, long-term memory reads and writes, short-term memory, and audit queries for custom integrations without an SDK.
API list
The following APIs are categorized by function.
Memory store management
API | Description |
| Creates a memory store. |
| Retrieves details of a memory store. |
| Updates the description of a memory store. |
| Deletes a memory store. |
| Lists memory stores. |
Long-term memory
API | Description |
| Adds conversation messages or text and generates long-term memories. |
| Searches long-term memories. |
| Lists long-term memories. |
| Retrieves a long-term memory. |
| Updates a long-term memory. |
| Deletes a long-term memory. |
Short-term memory and audit
API | Description |
| Queries short-term memories (raw session messages). |
| Queries the request audit records of a memory store. |
Common objects
The memory store APIs reuse the following data structures in requests and responses.
Scope
A Scope represents the ownership hierarchy for memory data and contains four fields.
Parameter | Type | Description |
| string | The application ID. |
| string | The tenant or user ID. |
| string | The Agent ID. |
| string | The session, run, or task ID. |
Scope field requirements and support for the * wildcard vary by API.
Scenario | Required fields | Wildcard |
Write ( |
| If optional fields are empty, they default to |
Search long-term memory ( |
| The |
Query short-term memory ( | All four Scope fields are required. | The |
Get, update, or delete a single long-term memory ( | All four Scope fields are required. | The |
List query ( |
| The |
Example:
{
"appId": "app-001",
"tenantId": "user-001",
"agentId": "assistant",
"runId": "session-001"
}Message
For the AddMemories API, the messages field uses the following structure.
Parameter | Type | Required | Description |
| string | Yes | The message role, such as |
| string | Yes | The message content. |
| string | No | The message ID. Maximum length: 256 characters. |
| string | No | Timestamp in RFC3339 format. |
| object | No | Message-level metadata. Both keys and values are strings. |
Metadata
Metadata consists of string key-value pairs that function as business tags. Search APIs use this metadata for exact match filtering.
Limit | Value |
Maximum keys per request | 16 |
Maximum key length | 64 characters |
Maximum value length | 1024 characters |
Example:
{
"source": "chat",
"topic": "preference"
}CreateMemoryStore
Creates a memory store.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. It must be no longer than 32 characters and contain only letters, numbers, and underscores (_). |
| string | No | An optional description of the memory store, with a maximum length of 1024 characters. |
Request example
{
"memoryStoreName": "agent_memory",
"description": "Long-term memory store for the agent"
}GetMemoryStore
Returns the details of a memory store.
Request parameters
Parameter | Type | Required | Description |
| string | true | The name of the memory store. |
Request example
{
"memoryStoreName": "agent_memory"
}UpdateMemoryStore
Updates the description of a memory store.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| string | Yes | The new description, with a maximum length of 1024 characters. |
DeleteMemoryStore
Deletes a memory store.
This is an irreversible operation that permanently deletes the memory store and all its data. Use caution in a production environment.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store to delete. |
ListMemoryStores
Lists memory stores.
Request parameters
Parameter | Type | Required | Description |
| int | No | The number of memory stores to return. |
| string | No | A token to retrieve the next page of results. |
AddMemories
Writes dialogue messages or text. The service saves the original messages as short-term memory and extracts long-term memory from the input.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the target memory store. |
| object | Yes | Scope. For write operations, |
| array | Required if | An array of dialogue messages. A maximum of 20 messages, with a total content length of up to 32,000 characters. |
| string | Required if | The text content. Maximum length: 32,000 characters. |
| object | No | Metadata for the write operation. A maximum of 16 key-value pairs. Keys are limited to 64 characters, and values are limited to 1,024 characters. |
| boolean | No | Specifies whether to wait for the memory extraction to complete synchronously. Defaults to |
For a full list of limits, see Limits and Notes.
Request example: add messages
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "assistant",
"runId": "session-001"
},
"messages": [
{
"role": "user",
"content": "I like coffee"
},
{
"role": "assistant",
"content": "Okay, I'll remember that."
}
],
"metadata": {
"source": "chat"
},
"sync": true
}Request example: add text
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001"
},
"text": "The user likes coffee and prefers concise answers."
}Response parameters
Parameter | Description |
| The request ID. |
| The status of the request. Asynchronous write operations typically return |
| The number of accepted messages. |
| The scope used for the write operation. |
| The name of the memory store. |
| Returned only for synchronous write operations. The number of memcells created. |
| Returned only for synchronous write operations. The number of long-term memory units created. |
SearchMemories
Retrieves long-term memory.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the target memory store. |
| string | Yes | The query text. |
| object | Yes | Scope. When you perform a retrieval, you must provide |
| int | No | The number of items to return, with a default value of |
| boolean | No | Specifies whether to enable Rerank. The default is |
| object | No | A metadata filter for exact-match queries. Both keys and values are strings. |
For a full description of the upper limit for topK, see Limits and notes.
Request example
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "*",
"runId": "*"
},
"query": "What drinks does the user like?",
"topK": 5,
"enableRerank": true,
"metadata": {
"source": "chat"
}
}Response fields
Field | Description |
| A list of search results. |
| A long-term memory unit. See the table below for a description of its fields. |
| The relevance score. |
| The scope used for the query. |
| The name of the memory store. |
The internal fields of results[].unit are as follows.
Field | Description |
| The long-term memory unit ID. |
| The associated conversation key. |
| The Scope of the memory is an object with four fields: |
| The memory cell ID. |
| The memory unit type. |
| The memory text. |
| The text used for retrieval. |
| A list of source message IDs. |
| The type label. |
| The date bucket. |
| The metadata, as a JSON string. |
| Indicates whether the unit is deleted. |
| The creation time. |
| The salience score. |
| The version number. |
ListMemories
Lists long-term memories.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| object | Yes | Scope. |
| int | No | The maximum number of long-term memories to return. |
| string | No | A token to retrieve the next page of results. |
Request example
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "*",
"agentId": "*",
"runId": "*"
},
"limit": 20
}GetMemory
Retrieves a single long-term memory.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The memory store name. |
| string | Yes | The memory ID. |
| object | Yes | For a full Scope, all 4 fields are required, and the wildcard character |
UpdateMemory
Updates a single long-term memory. You must provide at least one of text or metadata.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| string | Yes | The memory ID. |
| object | Yes | For a complete Scope, all 4 fields are required, and the wildcard character |
| string | No | The new memory text. |
| object | No | The new metadata. |
DeleteMemory
Deletes a single long-term memory item.
Deleting a long-term memory item is an irreversible operation. Proceed with caution in a production environment.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| string | Yes | The memory ID. |
| object | Yes | A complete scope requires all four fields and does not allow the wildcard character |
ListMemoryStoreMessages
Lists raw session messages from the short-term memory.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| object | Yes | For a complete Scope, all 4 fields are required, and wildcards such as |
| int | No | The maximum number of messages to return. |
| string | No | The token for the next page of results. |
| string | No | The minimum timestamp, in RFC3339 format. |
| string | No | The maximum timestamp, in RFC3339 format. |
Request example
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "user-001",
"agentId": "assistant",
"runId": "session-001"
},
"limit": 100
}ListMemoryStoreRequests
Queries the request audit records for a memory store.
Request parameters
Parameter | Type | Required | Description |
| string | Yes | The name of the memory store. |
| object | Yes | Scope. You can use the wildcard |
| string | No | The operation name, such as |
| int | No | The maximum number of records to return. |
| string | No | The token for the next page of results. |
| string | No | The minimum timestamp, in RFC 3339 format. |
| string | No | The maximum timestamp, in RFC 3339 format. |
Request example
{
"memoryStoreName": "agent_memory",
"scope": {
"appId": "app-001",
"tenantId": "*",
"agentId": "*",
"runId": "*"
},
"operation": "AddMemories",
"limit": 50
}Response parameters
Parameter | Description |
| The request ID. |
| The operation name. |
| The scope of the request. |
| The request summary. |
| The response status. |
| The latency in milliseconds. |
| The ID of the operation target, such as a memory ID. |
| The time when the record was created. |