更新记忆条目

更新时间:
复制为 MD 格式

更新指定记忆条目的内容,每次更新会自动递增版本号并生成版本记录。

更新指定记忆条目的内容。每次更新会自动递增版本号并生成版本记录。

请求头

头部

必选

说明

Authorization

Bearer

Content-Type

application/json

路径参数

参数

类型

必选

说明

memory_store_id

string

Memory Store ID(memstore_ 前缀)

memory_id

string

记忆条目 ID(mem_ 前缀)

请求体

字段

类型

必选

说明

content

string

新的记忆内容

version

integer

当前版本号(OCC 校验),必须与服务端当前版本一致

示例请求

curl -X PUT "https://api.qoder.com.cn/api/v1/cloud/memory_stores/memstore_xxx/memories/mem_xxx" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "更新后的内容...",
    "version": 1
  }'

示例响应

HTTP 200 OK

{
  "id": "mem_019e3bb965a671fca51bde1cf8d87de0",
  "type": "memory",
  "store_id": "memstore_019e3bb93b7074f9a5130d39ddcca90f",
  "path": "test/note.md",
  "content": "Hello world - updated content",
  "size": 29,
  "content_sha256": "663ab3dd969f51ffd6565202a6a5006db76a96a09a3506962f8d442df8f9bd76",
  "version": 2,
  "metadata": {},
  "created_at": "2026-05-18T15:34:26.494349Z",
  "updated_at": "2026-05-18T15:34:37.780345Z"
}

响应字段

字段

类型

说明

id

string

唯一标识符

type

string

固定值 "memory"

store_id

string

所属 Store ID

path

string

相对路径(不变)

content

string

更新后的内容

size

int64

新内容大小(字节)

content_sha256

string

新内容的 SHA-256 哈希

version

int64

递增后的版本号

metadata

object

自定义元数据

created_at

string

原始创建时间(不变)

updated_at

string

更新时间(ISO 8601)

错误码

HTTP

type

触发条件

401

authentication_error

未提供或无效的认证令牌

404

not_found_error

指定的 Memory Store 或记忆条目不存在

409

conflict_error

version 不匹配(并发修改)

注意事项

  • 每次更新 version 自动递增(如从 1 变为 2)

  • created_at 保持不变,updated_at 更新为当前时间

  • sizecontent_sha256 根据新内容重新计算

  • 每次更新会生成一条 action: "updated" 的版本记录

  • path 在更新时不可修改

完整错误信封说明详见 错误参考