---

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

orphan: true
---

# 更新智能体任务模板

更新已保存的智能体任务模板；未提供的字段保持原值。

```text
PATCH https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-task-templates/{template_id}
```

## 调用前准备

准备个人访问令牌、工作区 ID 和模板 ID。

## 路径参数

| 参数 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| `workspace_id` | string | 是 | 目标工作区 ID。 |
| `template_id` | string | 是 | 要更新的模板 ID。 |

## 请求体

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

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-task-templates/$TEMPLATE_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "description": "用于工作流中的摘要节点"
  }'
```

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

| 参数 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| `name` | string | 否 | 模板名称。 |
| `agent_id` | string | 否 | 要调用的智能体 ID。 |
| `description` | string | 否 | 模板说明。 |
| `message_template` | object | 否 | 任务消息模板。 |
| `input_schema` | object | 否 | 输入结构定义。 |
| `default_context_refs` | array | 否 | 默认上下文引用。 |
| `runtime_policy_ref` | string | 否 | 运行策略引用。 |
| `idempotency_policy` | object | 否 | 幂等策略。 |
| `output_contract` | object | 否 | 输出契约。 |
| `status` | string | 否 | 模板状态。 |
| `labels` | object | 否 | 标签键值对。 |
| `annotations` | object | 否 | 注解键值对。 |

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

## 成功响应

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

```json
{"code": 0, "data": {"id": "template_01", "description": "用于工作流中的摘要节点"}}
```

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

成功时返回 `200` 和更新后的模板。



响应字段如下。

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

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

:::

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

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `id` | string | 模板 ID。 |
| `description` | string | 更新后的模板说明。 |

:::
::::

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

## 错误响应

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

```json
{"code": 5, "message": "agent task template not found"}
```

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

### 常见 HTTP 错误

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

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `400` | `2` | **常见原因：**请求体无效。**建议操作：**检查要更新的字段。 |
| `404` | `5` | **常见原因：**模板不存在。**建议操作：**核对模板 ID。 |

:::
::::

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