All Products
Search
Document Center

Tablestore:Memory Storage API

Last Updated:Jul 09, 2026

Call Memory Storage directly through HTTP JSON APIs, covering memory store management, long-term memory read/write, short-term memory and audit queries, and memory consolidation (Dream) tasks. Use these APIs for custom integration without an SDK.

API list

All APIs grouped by category:

Memory store management

API

Description

CreateMemoryStore

Creates a memory store.

GetMemoryStore

Retrieves memory store details.

UpdateMemoryStore

Updates the description of a memory store.

DeleteMemoryStore

Deletes a memory store.

ListMemoryStores

Lists memory stores.

Long-term memory

API

Description

AddMemories

Writes conversation messages or text to generate long-term memories.

SearchMemories

Searches long-term memories.

ListMemories

Lists long-term memories.

GetMemory

Retrieves a long-term memory entry.

UpdateMemory

Updates a long-term memory entry.

DeleteMemory

Deletes a long-term memory entry.

Short-term memory and audit

API

Description

ListMemoryStoreMessages

Queries short-term memories (original conversation messages).

ListMemoryStoreRequests

Queries audit records of memory store requests.

Async tasks and Scope

API

Description

GetMemoryTask

Queries the status and result of an async extraction task.

ListMemoryTasks

Lists async extraction tasks.

ListMemoryStoreScopes

Lists the Scopes that exist in a memory store.

Memory dream

API

Description

CreateMemoryDreamTask

Creates a memory dream task.

GetMemoryDreamTask

Queries the progress of a memory dream task.

ListMemoryDreamTasks

Lists memory dream tasks.

ListMemoryDreamActions

Lists the actions (proposals) generated by a dream task.

ApplyMemoryDreamActions

Applies the proposed actions from a dream task.

CancelMemoryDreamTask

Cancels a memory dream task.

Common objects

Data structures shared across API requests and responses.

Scope

A Scope defines the ownership hierarchy of memory data.

Field

Type

Description

appId

string

The application identifier.

tenantId

string

The tenant or user identifier.

agentId

string

The agent identifier.

runId

string

The session, run, or task identifier.

Required Scope fields and wildcard * support vary by API.

Scenario

Required fields

Wildcard * rules

Write (AddMemories)

appId

Empty fields are populated with __default__. The wildcard * is not allowed.

Search long-term memories (SearchMemories)

appId and tenantId

agentId and runId support the wildcard *.

Query short-term memories (ListMemoryStoreMessages)

All four Scope fields

The wildcard * is not allowed.

Get, update, or delete a long-term memory entry (GetMemory, UpdateMemory, DeleteMemory)

All four Scope fields

The wildcard * is not allowed.

List queries (ListMemories, ListMemoryStoreRequests)

appId

The wildcard * is supported at each hierarchy level.

Example:

{
  "appId": "app-001",
  "tenantId": "user-001",
  "agentId": "assistant",
  "runId": "session-001"
}

Message

Structure for the messages field in AddMemories.

Field

Type

Required

Description

role

string

Yes

The message role, such as user, assistant, or system.

content

string

Yes

The message content.

messageId

string

No

The message ID. Maximum length: 256 characters.

timestamp

string

No

The timestamp in RFC 3339 format.

metadata

object

No

Message-level metadata. Keys and values must be strings.

Metadata

String key-value pairs for business tags. Search APIs use metadata for exact-match filtering.

Constraint

Value

Maximum keys per request

16

Maximum key length

64 characters

Maximum value length

1,024 characters

Example:

{
  "source": "chat",
  "topic": "preference"
}

CreateMemoryStore

Creates a memory store.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name. The name can contain only letters, digits, and underscores (_) and can be up to 32 characters in length.

description

string

No

The memory store description. Maximum length: 1,024 characters.

extractInstructions

string

No

The custom extraction instructions for the memory store. Maximum length: 4,096 characters.

Request example

{
  "memoryStoreName": "agent_memory",
  "description": "Long-term memory store for the agent",
  "extractInstructions": "Focus on the user's dining preferences and travel habits."
}

GetMemoryStore

Retrieves memory store details.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

Request example

{
  "memoryStoreName": "agent_memory"
}

UpdateMemoryStore

Updates the description of a memory store.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

description

string

Yes

The new description. Maximum length: 1,024 characters.

extractInstructions

string

No

The new custom extraction instructions. Maximum length: 4,096 characters. To clear the value, pass an empty string. To keep the current value, do not pass this field.

DeleteMemoryStore

Deletes a memory store.

Warning

Deleting a memory store permanently removes all its data. This action is irreversible. Proceed with caution in production environments.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

ListMemoryStores

Lists memory stores.

Request parameters

Field

Type

Required

Description

limit

int

No

The maximum number of entries to return.

nextToken

string

No

The pagination token for the next page.

AddMemories

Writes conversation messages or text. Raw messages are stored as short-term memories, and long-term memories are extracted from the input.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The target memory store name.

scope

object

Yes

The Scope. appId is required for write operations. The wildcard * is not allowed.

messages

array

Either text or messages is required

An array of conversation messages. Maximum: 20 messages, 32,000 characters total.

text

string

Either messages or text is required

The text content. Maximum length: 32,000 characters.

metadata

object

No

Write-level metadata. Maximum: 16 keys, 64-character keys, 1,024-character values.

sync

boolean

No

Whether to wait synchronously for memory extraction to complete. Default: false.

For the complete description of limits, see Limitations and notes.

Request example: Write messages

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "user-001",
    "agentId": "assistant",
    "runId": "session-001"
  },
  "messages": [
    {
      "role": "user",
      "content": "I like drinking coffee"
    },
    {
      "role": "assistant",
      "content": "OK, I'll remember that"
    }
  ],
  "metadata": {
    "source": "chat"
  },
  "sync": true
}

Request example: Write text

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "user-001"
  },
  "text": "The user likes coffee and prefers concise responses"
}

Response fields

Field

Description

requestId

The request ID.

status

The request status. Asynchronous writes typically return running.

acceptedMessages

The number of accepted messages.

scope

The Scope used for the write.

memoryStoreName

The memory store name.

memcellsCreated

Returned for synchronous writes. The number of memcells created.

unitsCreated

Returned for synchronous writes. The number of long-term memory units created.

SearchMemories

Searches long-term memories.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The target memory store name.

query

string

Yes

The query text.

scope

object

Yes

The Scope. appId and tenantId are required. agentId and runId support the wildcard *.

topK

int

No

Number of results to return. Default: 10. Valid values: 1 to 50.

includeEvidence

boolean

No

Specifies whether to include short-term memory source evidence (the evidence field) in the result. Default: false.

minSimilarity

float

No

The similarity filter threshold. Valid values: 0 to 1. Default: 0 (no filtering). When the value is greater than 0, results whose normalized cosine similarity is lower than this value are filtered out.

enableRerank

boolean

No

Whether to enable reranking. Default: true.

metadata

object

No

Metadata filters for exact matching. Keys and values must be strings.

For the complete description of the topK limit, see Limitations and notes.

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "user-001",
    "agentId": "*",
    "runId": "*"
  },
  "query": "What beverages does the user like",
  "topK": 5,
  "enableRerank": true,
  "includeEvidence": true,
  "metadata": {
    "source": "chat"
  }
}

Response fields

Field

Description

results

The list of search results.

results[].unit

The long-term memory unit. See the following table for field definitions.

results[].score

The relevance score.

results[].similarity

The normalized cosine similarity (0 to 1) between the query and the memory. This value is used by the minSimilarity filter.

results[].source

The hit source. Example: vector or vector+text.

evidence

The list of short-term memory source evidence returned when includeEvidence=true. Returns [] when no evidence is available. Each element has a structure similar to results, but contains only unit, score, and source, without similarity.

scope

The Scope used for the query.

memoryStoreName

The memory store name.

Fields in results[].unit:

Field

Description

id

The long-term memory unit ID.

conversation_key

The associated conversation key.

scope

The Scope to which the memory belongs. The object contains appId, tenantId, agentId, and runId.

memcell_id

The memcell ID.

unit_type

The memory unit type.

text

The memory text.

search_text

The text used for search.

source_turn_ids

The list of source message IDs.

type_label

The type label.

date_bucket

The date bucket.

metadata_json

The metadata in JSON string format.

deleted

Indicates whether the memory is deleted.

created_at

The creation time.

salience

The salience score.

version

The version number.

ListMemories

Lists long-term memories.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The Scope. appId and tenantId are required. agentId and runId support the wildcard *.

limit

int

No

The maximum number of entries to return.

nextToken

string

No

The pagination token for the next page.

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "*",
    "agentId": "*",
    "runId": "*"
  },
  "limit": 20
}

GetMemory

Retrieves a long-term memory entry.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

memoryId

string

Yes

The memory ID.

scope

object

Yes

The complete Scope. All four fields are required. The wildcard * is not allowed.

UpdateMemory

Updates a long-term memory entry. Specify at least one of text or metadata.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

memoryId

string

Yes

The memory ID.

scope

object

Yes

The complete Scope. All four fields are required. The wildcard * is not allowed.

text

string

No

The new memory text.

metadata

object

No

The new metadata.

DeleteMemory

Deletes a long-term memory entry.

Warning

Deleting a long-term memory entry is irreversible. Proceed with caution in production environments.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

memoryId

string

Yes

The memory ID.

scope

object

Yes

The complete Scope. All four fields are required. The wildcard * is not allowed.

ListMemoryStoreMessages

Queries short-term memories (original conversation messages).

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The complete Scope. All four fields are required. The wildcard * is not allowed.

limit

int

No

The maximum number of entries to return.

nextToken

string

No

The pagination token for the next page.

minTimestamp

string

No

The earliest time in RFC 3339 format.

maxTimestamp

string

No

The latest time in RFC 3339 format.

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "user-001",
    "agentId": "assistant",
    "runId": "session-001"
  },
  "limit": 100
}

Response example

{
  "session": {
    "scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" },
    "messages": [
      {
        "messageId": "d0d9dd778a27e8cde773a243a5bab13c",
        "role": "user",
        "speaker": "user",
        "content": "[10:00 AM on 13 May, 2026] From now on, always book me a window seat when I travel for business.",
        "timestamp": "2026-05-13T10:00:00Z",
        "metadata": { "channel": "chat", "source": "chat" }
      }
    ]
  }
}

If the memory store exists but no messages exist for the Scope, the operation returns 200 with an empty messages list.

ListMemoryStoreRequests

Queries audit records of memory store requests.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The Scope. The wildcard * is supported at each hierarchy level.

operation

string

No

The operation name, such as AddMemories or SearchMemories.

limit

int

No

The maximum number of entries to return.

nextToken

string

No

The pagination token for the next page.

minTimestamp

string

No

The earliest time in RFC 3339 format.

maxTimestamp

string

No

The latest time in RFC 3339 format.

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": {
    "appId": "app-001",
    "tenantId": "*",
    "agentId": "*",
    "runId": "*"
  },
  "operation": "AddMemories",
  "limit": 50
}

Response fields

Field

Description

requestId

The request ID.

operation

The operation name.

scope

The Scope used in the request.

requestSummary

The request summary.

responseStatus

The response status.

latencyMs

The processing latency in milliseconds.

targetId

The target ID of the operation, such as a memory ID.

createdAt

The creation time of the record.

GetMemoryTask

Queries the status and result of an async extraction task. Pass the requestId returned by AddMemories.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

requestId

string

Yes

The request ID returned by AddMemories.

scope

object

No

Validates the Scope of the task. You can use the wildcard * at any level.

Request example

{
  "memoryStoreName": "agent_memory",
  "requestId": "4b41a912f8c8a66202896e880a505d4a"
}

Response example

{
  "memoryStoreName": "agent_memory",
  "task": {
    "requestId": "4b41a912f8c8a66202896e880a505d4a",
    "eventType": "ingest",
    "memoryStoreName": "agent_memory",
    "conversationKey": "app-001/user-001/assistant/session-001",
    "scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" },
    "status": "completed",
    "acceptedMessages": 2,
    "derivedMemcellId": "b1bb4faec235b0d55bc8830da8ffa9f2",
    "derivedUnitIds": ["88432eb9d28e0787791625da916d6a20", "480230ab0806e88fd69e0804599552a4"],
    "createdAt": "2026-06-17T07:19:59.962Z",
    "updatedAt": "2026-06-17T07:20:08.749Z",
    "finishedAt": "2026-06-17T07:20:08.749Z"
  }
}

Valid values for the task status: queued, running, completed, failed, and needs_reconcile. While the ingest task index is being built after the first write, this API may return 409 CONFLICT (ingest task index is still building, please retry shortly). Retry the request after a short delay.

ListMemoryTasks

Lists async extraction tasks. The response returns task objects in the tasks array. Each element has the same structure as the task field in the GetMemoryTask response.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The Scope. You can use the wildcard * at any level.

status

string

No

Filters by task status: queued, running, completed, failed, or needs_reconcile.

limit

int

No

The maximum number of entries to return. Default: 50. Maximum: 100.

nextToken

string

No

The pagination token for the next page.

minTimestamp

string

No

The earliest time as a Unix timestamp in milliseconds (RFC 3339 is not supported).

maxTimestamp

string

No

The latest time as a Unix timestamp in milliseconds (RFC 3339 is not supported).

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" },
  "limit": 5
}

ListMemoryStoreScopes

Lists the Scopes that exist in a memory store. Use this operation to check which agents and sessions have produced memories under a given application or tenant.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The Scope. You can use the wildcard * at any level.

limit

int

No

The maximum number of entries to return. Default: 100. Maximum: 100.

nextToken

string

No

The pagination token for the next page.

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": { "appId": "app-001", "tenantId": "*", "agentId": "*", "runId": "*" },
  "limit": 10
}

Response example

{
  "memoryStoreName": "agent_memory",
  "scope": { "appId": "app-001", "tenantId": "*", "agentId": "*", "runId": "*" },
  "scopes": [
    { "appId": "app-001", "tenantId": "user-001", "agentId": "__default__", "runId": "__default__" },
    { "appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001" }
  ]
}

CreateMemoryDreamTask

Creates a memory dream task that performs secondary refinement, merging, and skill or profile extraction on memories that have been written. The task runs asynchronously.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scopes

array

Yes

The list of Scopes to organize. Up to 20 Scopes.

taskType

string

No

The task type: memory (default), skill, or profile.

applyMode

string

No

The apply mode: proposal (default; generates proposals only) or safe_auto (automatically applies safe actions). Supported only when taskType=memory.

scopeOutputMode

string

No

The result attribution mode: preserve_scope (default) or promote_scope.

confidenceThresholds

object

No

The confidence thresholds for automatic application, keyed by action: add, update, and merge. Valid values: 0 to 1.

minTimestamp / maxTimestamp

string

No

The time range for organization, as Unix timestamps in milliseconds (RFC 3339 is not supported).

maxSessions / maxMessages / maxMemories

int

No

The maximum input scale. For valid ranges, see the limits documentation.

expandedScopeLimit

int

No

The maximum number of expanded Scopes. Valid values: 0 to 1000.

instructions

string

No

The custom organization instructions. Maximum length: 4,000 characters.

incremental

boolean

No

Specifies whether to perform incremental organization. Default: false (full organization). When set to true, the task resumes from the last successful position.

clientToken

string

No

The idempotency token.

Request example

{
  "memoryStoreName": "agent_memory",
  "scopes": [ { "appId": "app-001", "tenantId": "user-001" } ],
  "taskType": "memory",
  "applyMode": "proposal"
}

Response example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "status": "queued",
  "createdAt": "2026-06-17T07:21:25.329Z"
}

GetMemoryDreamTask

Queries the progress and result summary of a memory dream task.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

dreamId

string

Yes

The ID of the dream task.

Request example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7"
}

Response example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "taskType": "memory",
  "applyMode": "proposal",
  "scopeOutputMode": "preserve_scope",
  "status": "completed",
  "actions": { "total": 2, "proposed": 2, "applied": 0, "skipped": 0, "failed": 0 },
  "input": { "scopes": [ { "appId": "app-001", "tenantId": "user-001", "agentId": "__default__", "runId": "__default__" } ], "sessionCount": 1, "messageCount": 1, "memoryCount": 2, "incremental": false },
  "lastError": "",
  "createdAt": "2026-06-17T07:21:25.329Z",
  "updatedAt": "2026-06-17T07:21:32.276Z",
  "finishedAt": "2026-06-17T07:21:32.276Z"
}

Valid values for the task status: queued, running, planning, applying, completed, completed_with_failures, failed, and cancelled.

ListMemoryDreamTasks

Lists memory dream tasks. The response returns task objects in the tasks array. Each element contains fields such as dreamId, status, taskType, actionCount, proposedCount, confidenceThresholds, and createdAt.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

scope

object

Yes

The Scope. You can use the wildcard * at any level.

status

string

No

Filters by task status.

limit

int

No

The maximum number of entries to return. Default: 50. Maximum: 100.

nextToken

string

No

The pagination token for the next page.

minTimestamp / maxTimestamp

string

No

The time range as Unix timestamps in milliseconds (RFC 3339 is not supported).

Request example

{
  "memoryStoreName": "agent_memory",
  "scope": { "appId": "app-001", "tenantId": "*", "agentId": "*", "runId": "*" },
  "limit": 10
}

ListMemoryDreamActions

Lists the actions (proposals) generated by a memory dream task.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

dreamId

string

No

The ID of the dream task. This parameter is mutually exclusive with scope.

scope

object

No

Queries by Scope. This parameter is mutually exclusive with dreamId. When you use scope, actionType is required and supports only EMIT_SKILL and EMIT_PROFILE.

status

string

No

Filters by action status: proposed, applied, skipped, or failed.

action

string

No

Filters by action type: ADD, UPDATE, DELETE, MERGE, or NOOP.

minConfidence / maxConfidence

float

No

Filters by confidence. Valid values: 0 to 1.

orderBy

string

No

The sort order: created_at_asc (default), created_at_desc, or confidence_desc.

limit

int

No

The maximum number of entries to return. Default: 100. Maximum: 100.

nextToken

string

No

The pagination token for the next page.

Request example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "limit": 20
}

Response example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "actions": [
    {
      "dreamId": "2a528008111f5dc3500c73fd965089f7",
      "actionId": "968768529cdfde8d56686a71e1c28227",
      "action": "UPDATE",
      "status": "proposed",
      "targetScope": { "appId": "app-001", "tenantId": "user-001", "agentId": "__default__", "runId": "__default__" },
      "targetMemoryId": "d16fd038835d89ae8586f7814e5256c1",
      "newMemory": { "text": "User prefers concise responses.", "unitType": "atomic_fact" },
      "reason": "Rewritten as a more precise atomic_fact statement.",
      "confidence": 0.95,
      "createdAt": "2026-06-17T07:21:32.161Z"
    }
  ]
}

The two query modes are mutually exclusive. Querying by dreamId returns all actions under the task. Querying by scope and actionType (only EMIT_SKILL or EMIT_PROFILE) returns the skills or profiles accumulated within that range.

ApplyMemoryDreamActions

Applies the proposed actions generated by a memory dream task (when applyMode=proposal).

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

dreamId

string

Yes

The ID of the dream task.

actionIds

array

Yes

The list of action IDs to apply. This list cannot be empty. A single request supports up to 100 action IDs.

applier

string

No

The identifier of the applier. This value is recorded in the audit log.

Request example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "actionIds": ["968768529cdfde8d56686a71e1c28227", "a0f4715245920ea7b6a34c1828c6f1ae"]
}

Response example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "applied": 2,
  "failed": 0,
  "results": [
    { "actionId": "968768529cdfde8d56686a71e1c28227", "status": "applied", "memoryId": "bd14a67ed215c114896325d912c8fa71" },
    { "actionId": "a0f4715245920ea7b6a34c1828c6f1ae", "status": "applied", "memoryId": "fa253856113f78d51a3b84a1fdf2d110" }
  ]
}

EMIT_SKILL and EMIT_PROFILE actions are written directly by the dream task and do not have a manual apply flow. Including action IDs of these types causes the request to be rejected. If actionIds is an empty array, the request returns 403.

CancelMemoryDreamTask

Cancels a memory dream task that has not finished.

Request parameters

Field

Type

Required

Description

memoryStoreName

string

Yes

The memory store name.

dreamId

string

Yes

The ID of the dream task.

Request example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7"
}

Response example

{
  "memoryStoreName": "agent_memory",
  "dreamId": "2a528008111f5dc3500c73fd965089f7",
  "status": "cancelled",
  "taskType": "memory"
}

Only tasks that have not finished can be canceled. For tasks that have already reached a terminal state (completed, failed, or cancelled), the response still returns 200 with the original status value, and the task itself is not modified.