Batch Update Memory
Apply up to 100 metadata edits in one request and read a per-item outcome for every one.
Endpoint and request fields
| Field | Type | Contract |
|---|---|---|
items | array | Required; 1–100 edits. |
items[].memory_id | integer | Required positive identifier. |
items[].tags | string[] | Optional replacement tag list. [] clears all tags. |
items[].importance | number | Optional value from 0 to 1. |
items[].metadata | object | Optional replacement metadata bag. Reserved keys are filtered out. |
items[].source | string | Optional source label. |
items[].event_type / eventType | string | Optional event label. |
Each item needs at least one editable field. An item that changes nothing is a request error, not a silent no-op.
Edit several memories
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ["MEMORYSYNC_PROJECT_ID"],end_user_id="usr_7f3a9c2e",)from memorysync import BatchUpdateItemresult = client.batch_update([BatchUpdateItem(memory_id=101, tags=["preference", "verified"], importance=0.9),BatchUpdateItem(memory_id=102, metadata={"reviewed_by": "support"}),])
Result paths
| Meaning | Python path | Node.js path | REST path |
|---|---|---|---|
| Totals | result.total, .updated, .not_found | result.total, .updated, .notFound | total, updated, not_found |
| Per-item outcome | result.results[i].status | result.results[i].status | results[i].status |
| Fields changed | result.results[i].changed_fields | result.results[i].changedFields | results[i].changed_fields |
{"total":3,"updated":2,"not_found":1,"results":[{"index":0,"memory_id":101,"status":"updated","changed_fields":["tags","importance"]},{"index":1,"memory_id":102,"status":"updated","changed_fields":["metadata"]},{"index":2,"memory_id":99999999,"status":"not_found","changed_fields":[]}]}
What is and is not atomic
All applied edits land in one transaction, so the batch either commits or it does not. An id the caller cannot see is reported as not_found rather than failing the request — it was never part of the transaction.
Reserved metadata keys
content_type, source, event_type, user_id, project_id, environment, feedback_log and feedback_patterns are platform-owned. A caller-supplied bag cannot set or overwrite them, and they survive a bag replacement. The first four drive retrieval filtering and data isolation, so being able to set them through metadata would let a memory answer for a different scope.
Errors and next action
A 422 means the request shape is wrong: an empty list, more than 100 items, the same memory_id twice, or an item with no editable field. Two edits to one memory have no defined order, so the duplicate is refused rather than resolved by position.