> ## 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 の作成

> 非同期のメモリ整理ジョブをトリガーします。

`POST /api/v1/cloud/dreams`

指定された Memory Store を非同期で整理する Dream を作成します。[Dream オブジェクト](/ja/cloud-agents/api/dreams/schemas#dream-object) を返します。

## ヘッダー

| ヘッダー            | 必須 | 説明                 |
| --------------- | -- | ------------------ |
| `Authorization` | はい | `Bearer <PAT>`     |
| `Content-Type`  | はい | `application/json` |

## リクエストボディ

| フィールド          | 型      | 必須  | 説明                                                               |
| -------------- | ------ | --- | ---------------------------------------------------------------- |
| `inputs`       | array  | はい  | 入力リスト。`memory_store` 型の入力を 1 つ含める必要があり、任意で `sessions` 型の入力を含められる |
| `model`        | string | いいえ | モデル選択: `auto`（デフォルト）、`lite`、`ultimate`                           |
| `instructions` | string | いいえ | カスタム整理指示、最大 4096 文字                                              |

### inputs 要素

| フィールド             | 型      | 説明                                |
| ----------------- | ------ | --------------------------------- |
| `type`            | string | `"memory_store"` または `"sessions"` |
| `memory_store_id` | string | type が `memory_store` の場合に必須      |
| `session_ids`     | array  | type が `sessions` の場合に必須、最大 100 件 |

## リクエスト例

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/cloud/dreams' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      { "type": "memory_store", "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4" },
      { "type": "sessions", "session_ids": ["sess_019e7a1b2c3d4e5f6a7b8c9d0e1f2a3b"] }
    ],
    "model": "auto",
    "instructions": "Focus on user preferences for code style"
  }'
```

## レスポンス例

**HTTP 201 Created**

```json theme={null}
{
  "id": "drm_019e86b4a8f070a3b6c5d4e3f2a1b0c9",
  "type": "dream",
  "status": "pending",
  "inputs": [
    { "type": "memory_store", "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4" },
    { "type": "sessions", "session_ids": ["sess_019e7a1b2c3d4e5f6a7b8c9d0e1f2a3b"] }
  ],
  "outputs": [],
  "model": { "id": "auto" },
  "instructions": "Focus on user preferences for code style",
  "session_id": null,
  "usage": { "input_tokens": 0, "output_tokens": 0, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 },
  "error": null,
  "created_at": "2026-06-15T10:00:00Z",
  "ended_at": null,
  "archived_at": null
}
```

## エラー

| HTTP | 種別                      | トリガー                                                                                        |
| ---- | ----------------------- | ------------------------------------------------------------------------------------------- |
| 400  | `invalid_request_error` | inputs が空、memory\_store 入力欠落、memory\_store の重複、sessions が 100 件超過、無効なモデル、instructions が長すぎる |
| 401  | `authentication_error`  | 認証トークンが欠落または無効                                                                              |
| 404  | `not_found_error`       | 参照された Memory Store が存在しないかアクセス不可                                                            |
| 409  | `invalid_request_error` | ユーザーにすでにアクティブな Dream（pending または running）がある                                                |

完全なエラーエンベロープは [エラーリファレンス](/ja/cloud-agents/api/conventions/errors) を参照してください。
