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

# 手动触发 Deployment

> 手动触发一次 Deployment 运行。

`POST /api/v1/cloud/deployments/{id}/run`

手动触发一次 Deployment 运行。Deployment 必须处于 `active` 状态（非暂停或已归档）。如果 CAS 无法为本次运行创建 Session，返回的 Deployment Run 会包含 `session_id: null` 和 `error` 对象。

## 路径参数

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

## 请求头

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

## 请求体

无需请求体。可发送空 JSON `{}` 或省略。

## 示例请求

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/deployments/dep_019ec55a2b687b3f94eee77dd77e4b2a/run" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json"
```

## 示例响应

**HTTP 200 OK**

返回 Deployment Run 对象。

```json theme={null}
{
  "agent": {
    "id": "agent_019ebb21ef8e7df6a559052c94875160",
    "type": "agent",
    "version": 1
  },
  "created_at": "2026-06-14T08:58:17Z",
  "deployment_id": "dep_019ec55a2b687b3f94eee77dd77e4b2a",
  "error": null,
  "id": "drun_019ec55a68af73028afa5b87931cb2f3",
  "session_id": "sess_019ec55a68b37e1e8d660691af161ab4",
  "trigger_context": {
    "type": "manual"
  },
  "type": "deployment_run"
}
```

## 响应字段（Deployment Run）

| 字段                | 类型            | 说明                                                                        |
| ----------------- | ------------- | ------------------------------------------------------------------------- |
| `id`              | string        | Run 唯一标识（`drun_` 前缀）                                                      |
| `type`            | string        | 固定值 `"deployment_run"`                                                    |
| `deployment_id`   | string        | 所属 Deployment ID                                                          |
| `agent`           | object        | Agent 引用：`{id, type, version}`                                            |
| `error`           | object 或 null | 运行未能创建 Session 时的错误详情（`{message, type}`）；存在 `session_id` 时为 null          |
| `trigger_context` | object        | 触发来源：`{"type": "manual"}` 或 `{"type": "schedule", "scheduled_at": "..."}` |
| `session_id`      | string 或 null | 关联的 Session ID。公开 Run 行中 `session_id` 与 `error` 只会有一个非 null               |
| `created_at`      | string        | 记录创建时间（ISO 8601）                                                          |

## 错误码

| HTTP | type                   | 触发条件                          |
| ---- | ---------------------- | ----------------------------- |
| 401  | `authentication_error` | PAT 无效或过期                     |
| 404  | `not_found_error`      | Deployment 不存在                |
| 409  | `conflict_error`       | Deployment 已归档或不在 `active` 状态 |

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

## 相关

<CardGroup cols={2}>
  <Card title="获取 Deployment Run" icon="code" href="/zh/cloud-agents/api/deployments/get-run">
    查看单次运行的状态与 Session ID。
  </Card>

  <Card title="列出 Deployment Run" icon="clock" href="/zh/cloud-agents/api/deployments/list-runs">
    查看该 Deployment 的运行历史。
  </Card>

  <Card title="列出所有 Run" icon="layer-group" href="/zh/cloud-agents/api/deployments/list-all-runs">
    跨 Deployment 查询所有运行记录。
  </Card>

  <Card title="获取 Deployment" icon="rocket" href="/zh/cloud-agents/api/deployments/get">
    查看 Deployment 配置与下次调度时间。
  </Card>
</CardGroup>
