The whole hunk
from line 28, old and new numbered
/
lines
from line 28
2828
2929Give the store a `name` and a `description`. The description is passed to the agent, telling it what the store contains.
3030
31<CodeGroup defaultLanguage="CLI">
31<CodeGroup>
3232 ```bash cURL
33 store=$(curl -s https://api.anthropic.com/v1/memory_stores \
33 curl -s https://api.anthropic.com/v1/memory_stores \
3434 -H "x-api-key: $ANTHROPIC_API_KEY" \
3535 -H "anthropic-version: 2023-06-01" \
3636 -H "anthropic-beta: agent-memory-2026-07-22" \
3737 -H "content-type: application/json" \
38 -d '{"name": "User Preferences", "description": "Per-user preferences and project context."}')
39 store_id=$(jq -r '.id' <<< "$store")
40 echo "$store_id" # memstore_01Hx...
38 -d '{"name": "User Preferences", "description": "Per-user preferences and project context."}'
4139 ```
4240
4341 ```bash CLI
44 store_id=$(ant beta:memory-stores create \
42 ant beta:memory-stores create \
4543 --name "User Preferences" \
46 --description "Per-user preferences and project context." \
47 --transform id --raw-output)
44 --description "Per-user preferences and project context."
4845 ```
4946
5047 ```python Python
from line 121
124121
125122Pre-load a store with reference material before any agent runs:
126123
127<CodeGroup defaultLanguage="CLI">
124<CodeGroup>
128125 ```bash cURL
129126 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memories" \
130127 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 211
214211
215212You can configure `access` as well. It defaults to `read_write` (shown explicitly in the following example), but `read_only` is also supported.
216213
217<CodeGroup defaultLanguage="CLI">
214<CodeGroup>
218215 ```bash cURL
219216 curl -s https://api.anthropic.com/v1/sessions \
220217 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 397
400397* `path_prefix` scopes the list to one directory. It must end with `/` and matches whole path segments, so `path_prefix=/notes/` returns `/notes/todo.md` but not `/notes-archive/todo.md`.
401398* `depth` controls how deep the listing goes below `path_prefix`: omit it (or pass `0`) to list the whole subtree, or pass `1` to list only the immediate children. Other values return a `400` error.
402399
403<CodeGroup defaultLanguage="CLI">
400<CodeGroup>
404401 ```bash cURL
405402 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memories?path_prefix=/" \
406403 -H "x-api-key: $ANTHROPIC_API_KEY" \
407404 -H "anthropic-version: 2023-06-01" \
408 -H "anthropic-beta: agent-memory-2026-07-22" | jq -r '.data[] | "\(.type) \(.path)"'
405 -H "anthropic-beta: agent-memory-2026-07-22"
409406 ```
410407
411408 ```bash CLI
from line 493
496493
497494Fetching an individual memory returns the full content.
498495
499<CodeGroup defaultLanguage="CLI">
496<CodeGroup>
500497 ```bash cURL
501498 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memories/$mem_id" \
502499 -H "x-api-key: $ANTHROPIC_API_KEY" \
503500 -H "anthropic-version: 2023-06-01" \
504 -H "anthropic-beta: agent-memory-2026-07-22" | jq -r '.content'
501 -H "anthropic-beta: agent-memory-2026-07-22"
505502 ```
506503
507504 ```bash CLI
from line 568
571568
572569`memories.create` creates a memory at a given `path`. Create does not overwrite; to change an existing memory, use [`memories.update`](https://platform.claude.com/docs/en/managed-agents/memory#update-a-memory).
573570
574<CodeGroup defaultLanguage="CLI">
571<CodeGroup>
575572 ```bash cURL
576 mem=$(curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memories" \
573 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memories" \
577574 -H "x-api-key: $ANTHROPIC_API_KEY" \
578575 -H "anthropic-version: 2023-06-01" \
579576 -H "anthropic-beta: agent-memory-2026-07-22" \
580577 -H "content-type: application/json" \
581 -d '{"path": "/preferences/formatting.md", "content": "Always use tabs, not spaces."}')
582 mem_id=$(jq -r '.id' <<< "$mem")
583 mem_sha=$(jq -r '.content_sha256' <<< "$mem")
578 -d '{"path": "/preferences/formatting.md", "content": "Always use tabs, not spaces."}'
584579 ```
585580
586581 ```bash CLI
587 mem=$(ant beta:memory-stores:memories create \
582 ant beta:memory-stores:memories create \
588583 --memory-store-id "$store_id" \
589584 --path "/preferences/formatting.md" \
590 --content "Always use tabs, not spaces." \
591 --format json)
592 mem_id=$(jq -r '.id' <<< "$mem")
593 mem_sha=$(jq -r '.content_sha256' <<< "$mem")
585 --content "Always use tabs, not spaces."
594586 ```
595587
596588 ```python Python
from line 651
659651
660652`memories.update` modifies an existing memory by ID. You can change `content`, `path` (a rename), or both. The example renames a memory to an archive path:
661653
662<CodeGroup defaultLanguage="CLI">
654<CodeGroup>
663655 ```bash cURL
664656 curl -s -X POST "https://api.anthropic.com/v1/memory_stores/$store_id/memories/$mem_id" \
665657 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 735
743735
744736To avoid clobbering a concurrent write, pass a `content_sha256` precondition. The update only applies if the stored content hash still matches the one you read; on mismatch, re-read the memory and retry against the fresh state.
745737
746<CodeGroup defaultLanguage="CLI">
738<CodeGroup>
747739 ```bash cURL
748740 curl -s -X POST "https://api.anthropic.com/v1/memory_stores/$store_id/memories/$mem_id" \
749741 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 840
848840
849841### Delete a memory
850842
851<CodeGroup defaultLanguage="CLI">
843<CodeGroup>
852844 ```bash cURL
853845 curl -s -X DELETE "https://api.anthropic.com/v1/memory_stores/$store_id/memories/$mem_id" \
854846 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 919
927919
928920List version history for a store, newest first. The example filters to a single memory's history:
929921
930<CodeGroup defaultLanguage="CLI">
922<CodeGroup>
931923 ```bash cURL
932 versions=$(curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memory_versions?memory_id=$mem_id" \
924 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memory_versions?memory_id=$mem_id" \
933925 -H "x-api-key: $ANTHROPIC_API_KEY" \
934926 -H "anthropic-version: 2023-06-01" \
935 -H "anthropic-beta: agent-memory-2026-07-22")
936 jq -r '.data[] | "\(.id): \(.operation)"' <<< "$versions"
937 version_id=$(jq -r '.data[1].id' <<< "$versions")
927 -H "anthropic-beta: agent-memory-2026-07-22"
938928 ```
939929
940930 ```bash CLI
941 versions=$(ant beta:memory-stores:memory-versions list \
931 ant beta:memory-stores:memory-versions list \
942932 --memory-store-id "$store_id" \
943933 --memory-id "$mem_id" \
944 --format json)
945 # `list --format json` emits one JSON object per item.
946 jq -r '"\(.id): \(.operation)"' <<< "$versions"
947 version_id=$(jq -rs '.[1].id' <<< "$versions")
934 --format json
948935 ```
949936
950937 ```python Python
from line 1035
10481035
10491036Fetching an individual version returns the same fields as the list response plus the full `content` body.
10501037
1051<CodeGroup defaultLanguage="CLI">
1038<CodeGroup>
10521039 ```bash cURL
10531040 curl -s "https://api.anthropic.com/v1/memory_stores/$store_id/memory_versions/$version_id" \
10541041 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 1115
11281115
11291116A version that is the current head of a live memory cannot be redacted. Write a new version first (or delete the memory), then redact the old one.
11301117
1131<CodeGroup defaultLanguage="CLI">
1118<CodeGroup>
11321119 ```bash cURL
11331120 curl -s -X POST "https://api.anthropic.com/v1/memory_stores/$store_id/memory_versions/$version_id/redact" \
11341121 -H "x-api-key: $ANTHROPIC_API_KEY" \
from line 1192
12051192
12061193List stores in the workspace. Archived stores are excluded by default; pass `include_archived: true` to include them.
12071194
1208<CodeGroup defaultLanguage="CLI">
1195<CodeGroup>
12091196 ```bash cURL
12101197 curl -s "https://api.anthropic.com/v1/memory_stores?include_archived=true" \
12111198 -H "x-api-key: $ANTHROPIC_API_KEY" \
12121199 -H "anthropic-version: 2023-06-01" \
1213 -H "anthropic-beta: agent-memory-2026-07-22" | jq '.data[] | {id, name, archived_at}'
1200 -H "anthropic-beta: agent-memory-2026-07-22"
12141201 ```
12151202
12161203 ```bash CLI
from line 1265
12781265
12791266Archiving makes a store read-only and prevents it from being attached to new sessions. Archiving is one-way; there is no unarchive.
12801267
1281<CodeGroup defaultLanguage="CLI">
1268<CodeGroup>
12821269 ```bash cURL
12831270 curl -s -X POST "https://api.anthropic.com/v1/memory_stores/$store_id/archive" \
12841271 -H "x-api-key: $ANTHROPIC_API_KEY" \