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

# 归档 Dream

> 归档一个已完成的 Dream。

`POST /api/v1/cloud/dreams/{id}/archive`

归档指定的 Dream。只有终态（`completed`、`failed`、`canceled`）的 Dream 可以归档。已归档的 Dream 再次调用此接口是幂等的。返回更新后的 [Dream 对象](/cloud-agents/api/dreams/schemas#dream-对象)。

归档后的 Dream 默认不出现在列表接口中，除非传入 `include_archived=true`。

## 请求头

| 头部              | 必选 | 说明             |
| --------------- | -- | -------------- |
| `Authorization` | 是  | `Bearer <PAT>` |

## 路径参数

| 参数   | 类型     | 说明                  |
| ---- | ------ | ------------------- |
| `id` | string | Dream ID（`drm_` 前缀） |

## 示例请求

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/cloud/dreams/drm_019e86b4a8f070a3b6c5d4e3f2a1b0c9/archive' \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "id": "drm_019e86b4a8f070a3b6c5d4e3f2a1b0c9",
  "type": "dream",
  "status": "completed",
  "inputs": [{ "type": "memory_store", "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4" }],
  "outputs": [{ "type": "memory_store", "memory_store_id": "memstore_019e86b4b10578059435632bb357c5ed", "files_touched": ["preferences.md"] }],
  "model": { "id": "auto" },
  "instructions": "",
  "session_id": "sess_019e86b4b10578059435632bb357c5ed",
  "usage": { "input_tokens": 12500, "output_tokens": 3200, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 8000 },
  "error": null,
  "created_at": "2026-06-15T10:00:00Z",
  "ended_at": "2026-06-15T10:03:42Z",
  "archived_at": "2026-06-15T12:00:00Z"
}
```

## 错误码

| HTTP | Type                    | 触发条件                                |
| ---- | ----------------------- | ----------------------------------- |
| 400  | `invalid_request_error` | Dream 处于 pending 或 running 状态（需先取消） |
| 401  | `authentication_error`  | 缺少或无效的认证令牌                          |
| 404  | `not_found_error`       | Dream 不存在                           |

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