Skip to main content

memories

Creates, updates, deletes, gets or lists a memories resource.

Overview​

Namememories
TypeResource
Idanthropic.memory_stores.memories

Fields​

The following fields are returned by SELECT queries:

Successful response (OK)

NameDatatypeDescription
idstringUnique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.
memory_store_idstringID of the memory store this memory belongs to (a `memstore_...` value).
memory_version_idstringID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the history via [List memory versions](/en/api/beta/memory_stores/memory_versions/list).
contentstringThe memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).
content_sha256stringLowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.
content_size_bytesinteger (int32)Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.
created_atstring (date-time)When this memory was created, in RFC 3339 format.
pathstringHierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.
typestring (memory)
updated_atstring (date-time)When this memory was last modified, in RFC 3339 format. Use this as a cheap freshness signal; for who made the change, look up the head version's `created_by` via [List memory versions](/en/api/beta/memory_stores/memory_versions/list).

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectmemory_store_id, memory_idview, anthropic-workspace-id
listselectmemory_store_idpath_prefix, depth, view, anthropic-workspace-id
createinsertmemory_store_id, path, contentview, anthropic-workspace-id
updateupdatememory_store_id, memory_idview, anthropic-workspace-id
deletedeletememory_store_id, memory_idexpected_content_sha256, anthropic-workspace-id

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
memory_idstringThe ID of the memory to delete (mem_...).
memory_store_idstringThe ID of the memory store that holds the memory (memstore_...).
anthropic-workspace-idstringOptional header to select the Workspace for this request. The value is a Workspace ID (for example, wrkspc_011CZkZaBF1tNoB5wlCeusgy). Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace. (example: wrkspc_011CZkZaBF1tNoB5wlCeusgy)
depthinteger (int32)0 (or omitted) returns all descendants below path_prefix (recursive). 1 returns immediate children only; deeper entries roll up as memory_prefix items. depth=1 behaves like ls; omitting depth behaves like find.
expected_content_sha256stringDelete the memory only if its current content_sha256 equals this value, given as 64 lowercase hexadecimal characters. Omit it to delete unconditionally. If the hashes differ, the request fails with HTTP status 409 and nothing is deleted.
path_prefixstringOptional path prefix filter. Must end with / (segment-aligned), e.g., /notes/. This value appears in request URLs. Do not include secrets or personally identifiable information.
viewstring

SELECT examples​

Successful response (OK)

SELECT
id,
memory_store_id,
memory_version_id,
content,
content_sha256,
content_size_bytes,
created_at,
path,
type,
updated_at
FROM anthropic.memory_stores.memories
WHERE memory_store_id = '{{ memory_store_id }}' -- required
AND memory_id = '{{ memory_id }}' -- required
AND view = '{{ view }}'
AND "anthropic-workspace-id" = '{{ anthropic-workspace-id }}'
;

INSERT examples​

No description available.

INSERT INTO anthropic.memory_stores.memories (
path,
content,
memory_store_id,
view,
"anthropic-workspace-id"
)
SELECT
'{{ path }}' /* required */,
'{{ content }}' /* required */,
'{{ memory_store_id }}',
'{{ view }}',
'{{ anthropic-workspace-id }}'
RETURNING
id,
memory_store_id,
memory_version_id,
content,
content_sha256,
content_size_bytes,
created_at,
path,
type,
updated_at
;

UPDATE examples​

No description available.

UPDATE anthropic.memory_stores.memories
SET
content = '{{ content }}',
path = '{{ path }}',
precondition = '{{ precondition }}'
WHERE
memory_store_id = '{{ memory_store_id }}' --required
WHERE memory_id = '{{ memory_id }}' --required
AND view = '{{ view}}'
AND "anthropic-workspace-id" = '{{ anthropic-workspace-id}}'
RETURNING
id,
memory_store_id,
memory_version_id,
content,
content_sha256,
content_size_bytes,
created_at,
path,
type,
updated_at;

DELETE examples​

No description available.

DELETE FROM anthropic.memory_stores.memories
WHERE memory_store_id = '{{ memory_store_id }}' --required
AND memory_id = '{{ memory_id }}' --required
AND expected_content_sha256 = '{{ expected_content_sha256 }}'
AND "anthropic-workspace-id" = '{{ anthropic-workspace-id }}'
;