Update Memory

Updated at:

Modifies the body, renames, or updates atomically. At least one of `path` and `content` must be present. A real change produces a `modified` version. Returns updated metadata without the body.

Prerequisites

Endpoint and authentication configured. For details, see Overview and authentication.

Endpoint

POST/memory_stores/{memory_store_id}/memories/{memory_id}

Path parameters

memory_store_idstringRequired

Memory store ID

memory_idstringRequired

Memory ID

Request body

pathstringOptional

New path (rename), same rules as creation; the memory ID stays unchanged

contentstringOptional

New body, up to 102400 UTF-8 bytes

preconditionobjectOptional

Optional optimistic lock: carries the content_sha256 obtained at read time; returns a conflict if the content has been modified

Response fields

idstring

Memory ID, format mem_xxx

typestring

Always memory

memory_store_idstring

ID of the owning memory store

pathstring

Path inside the memory store, starting with /

content_sha256string

SHA256 of the body; can be used as the optimistic lock for conditional updates

content_size_bytesinteger

Body length in UTF-8 bytes

memory_version_idstring

Current version ID, format memver_xxx

created_atstring

Creation time, ISO 8601 UTC

updated_atstring

Last update time, ISO 8601 UTC

Request example

curl -X POST "$AGENTSTUDIO_URL/memory_stores/memstore_xxx/memories/mem_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"content": "# Project Conventions\nThe default development environment is staging.\nChanges require regression tests.\n","precondition": {"type": "content_sha256","content_sha256": "e3b0c44b98fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}}'

Response example

{
  "id": "mem_xxx",
  "type": "memory",
  "memory_store_id": "memstore_xxx",
  "path": "/notes/project.md",
  "content_sha256": "e3b0c44b98fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  "content_size_bytes": 47,
  "memory_version_id": "memver_yyy",
  "created_at": "2026-09-17T08:00:00Z",
  "updated_at": "2026-09-17T08:30:00Z"
}

Error codes

HTTP statusError codeDescription
400invalid_request_errorInvalid parameters, path, limit, or pagination cursor
401InvalidApiKeyAPI key missing, invalid, or expired
403permission_errorInsufficient identity or resource access permissions
404not_found_errorResource does not exist or does not belong to the current workspace
409memory_path_conflict_error etc.Path conflict, conditional update conflict, or writing to an archived store