> ## 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.

# 创建 Memory

> 在 Store 中创建一条新的 memory。

`POST /api/v1/cloud/memory_stores/{memory_store_id}/memories`

创建一条新的 memory，返回的对象包含 `content`。

## 路径参数

| 参数                | 说明                              |
| ----------------- | ------------------------------- |
| `memory_store_id` | Memory Store ID（`memstore_...`） |

## 请求头

| 头部              | 必选 | 说明                 |
| --------------- | -- | ------------------ |
| `Authorization` | 是  | `Bearer <PAT>`     |
| `Content-Type`  | 是  | `application/json` |

## 请求体

| 字段         | 类型     | 必选 | 说明                                           |
| ---------- | ------ | -- | -------------------------------------------- |
| `path`     | string | 是  | memory 路径，最长 1024 字符。不能以 `/` 开头，不能包含 `..`    |
| `content`  | string | 是  | memory 内容，最大 100 KB                          |
| `metadata` | object | 否  | 自定义键值元数据。最多 16 对；key 1–64 字符；value 最长 512 字符 |

## 示例请求

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/memory_stores/memstore_xxx/memories" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "decisions/arch-choice.md",
    "content": "# 架构决策\n\n选择微服务架构。"
  }'
```

## 示例响应

```json theme={null}
{
  "id": "mem_019e5cdba1b674e4a6a7d4f8c9b3e2a1",
  "type": "memory",
  "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4",
  "path": "decisions/arch-choice.md",
  "content": "# 架构决策\n\n选择微服务架构。",
  "content_size_bytes": 46,
  "content_sha256": "a1b2c3...",
  "version": 1,
  "metadata": {},
  "created_at": "2026-05-18T08:01:00.000Z",
  "updated_at": "2026-05-18T08:01:00.000Z"
}
```

## 错误码

| HTTP | type                    | 触发条件                          |
| ---- | ----------------------- | ----------------------------- |
| 400  | `invalid_request_error` | `path` 非法，或 `content` 为空 / 超限 |
| 404  | `not_found_error`       | Store 不存在                     |
| 409  | `invalid_request_error` | Store 已归档，或 `path` 已存在        |

完整错误信封说明详见 [错误参考](/zh/cloud-agents/api/conventions/errors)。
