---

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

orphan: true
---

# 创建智能体工作流绑定

为一个工作流节点绑定智能体任务模板。创建成功仅保存绑定，不会创建计划或执行任务。

```text
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-workflow-bindings
```

## 调用前准备



## 请求体

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} 调用示例

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-workflow-bindings" -H "X-API-Key: $AI_STUDIO_API_KEY" -H "X-Workspace-ID: $WORKSPACE_ID" -H 'Content-Type: application/json' -d '{"workflow_id":"'$WORKFLOW_ID'","node_id":"summary","agent_task_template_id":"'$TEMPLATE_ID'"}'
```

:::::
:::::{tab-item} 参数说明

| 参数 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| `workflow_id` | string | 是 | 工作流 ID。 |
| `node_id` | string | 是 | 工作流节点 ID。 |
| `agent_task_template_id` | string | 是 | 智能体任务模板 ID。 |
| `workflow_version_id` | string | 否 | 工作流版本 ID。 |
| `input_mapping` | object | 否 | 输入映射。 |
| `output_mapping` | object | 否 | 输出映射。 |
| `failure_mapping` | object | 否 | 失败处理映射。 |
| `status` | string | 否 | 绑定状态。 |
| `labels` | object | 否 | 标签键值对。 |
| `annotations` | object | 否 | 注解键值对。 |

:::::
::::::
:::::::

## 成功响应

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{"code": 0, "data": {"id": "binding_01", "workflow_id": "wf_01", "node_id": "summary", "agent_task_template_id": "template_01"}}
```

:::::
:::::{tab-item} 字段说明

成功时返回 `201` 和新建绑定。



响应字段如下。

::::{tab-set}
:::{tab-item} 通用字段

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | integer | 成功时为 `0`。 |

:::

:::{tab-item} 基本信息

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `id` | string | 新建绑定 ID。 |
| `workflow_id` | string | 工作流 ID。 |
| `agent_task_template_id` | string | 关联模板 ID。 |

:::
::::

:::::
::::::
:::::::

## 错误响应

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{"code": 4, "message": "agent workflow binding already exists"}
```

:::::
:::::{tab-item} 字段说明

### 常见 HTTP 错误

::::{tab-set}
:::{tab-item} 通用字段

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `400` | `2` | **常见原因：**绑定字段无效。**建议操作：**检查工作流、节点和模板标识。 |
| `409` | `4` | **常见原因：**同一工作流节点已有绑定。**建议操作：**查询或更新已有绑定。 |

:::
::::

:::::
::::::
:::::::
