跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

POST /v1/memory_stores/{memory_store_id}/memories 在指定的 Memory Store 中创建一条新的记忆条目。

请求头

头部必选说明
AuthorizationBearer <PAT>
Content-Typeapplication/json

路径参数

参数类型必选说明
memory_store_idstringMemory Store ID(memstore_ 前缀)

请求体

字段类型必选说明
pathstring相对路径(不能以 / 开头)
contentstring记忆内容(文本)

示例请求

curl -X POST "https://openapi.qoder.sh/api/v1/cloud/memory_stores/memstore_xxx/memories" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "notes/meeting.md",
    "content": "会议纪要内容..."
  }'

示例响应

HTTP 201 Created
{
  "id": "mem_019e3bb965a671fca51bde1cf8d87de0",
  "type": "memory",
  "store_id": "memstore_019e3bb93b7074f9a5130d39ddcca90f",
  "path": "notes/meeting.md",
  "content": "会议纪要内容...",
  "size": 11,
  "content_sha256": "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c",
  "version": 1,
  "metadata": {},
  "created_at": "2026-05-18T15:34:26.494349Z",
  "updated_at": "2026-05-18T15:34:26.494349Z"
}

响应字段

字段类型说明
idstring唯一标识符(mem_ 前缀)
typestring固定值 "memory"
store_idstring所属 Memory Store 的 ID
pathstring相对路径
contentstring记忆内容
sizeint64内容大小(字节)
content_sha256string内容 SHA-256 哈希
versionint64版本号(首次创建为 1)
metadataobject自定义元数据
created_atstring创建时间(ISO 8601)
updated_atstring最后更新时间(ISO 8601)

错误码

HTTPtype触发条件
400invalid_request_error请求参数错误(如 path/ 开头)
401authentication_error未提供或无效的认证令牌
404not_found_error指定的 Memory Store 不存在
409conflict_error同一 Store 下已存在相同 path 的条目
错误响应示例: path/ 开头:
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Field 'path' must be a relative path (cannot start with '/')."
  }
}
路径冲突:
{
  "type": "error",
  "error": {
    "type": "conflict_error",
    "message": "Version or state conflict."
  }
}

注意事项

  • path 必须是相对路径,不能以 / 开头
  • 同一 Store 下不能有两个相同 path 的记忆条目(返回 409)
  • 创建时版本号初始为 1
  • 服务端自动计算 sizecontent_sha256
  • 创建操作会同步生成一条 action: "created" 的版本记录
完整错误信封说明详见 错误参考