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

# 克隆 Template

> 基于现有 Template 创建副本。

`POST /api/v1/forward/templates/{template_id}/clone`

复制源 Template 的 Agent 配置和 Session 默认配置，并生成新的 Template ID。

## 请求头

| Header          | 是否必填 | 说明                 |
| --------------- | ---- | ------------------ |
| Authorization   | 是    | `Bearer <PAT>`     |
| Content-Type    | 是    | `application/json` |
| Idempotency-Key | 否    | 有副作用请求可选的幂等键。      |

## 路径参数

| 参数           | 类型     | 是否必填 | 说明                     |
| ------------ | ------ | ---- | ---------------------- |
| template\_id | string | 是    | 源 Forward Template ID。 |

## 请求体参数

| 参数          | 类型     | 是否必填 | 说明                               |
| ----------- | ------ | ---- | -------------------------------- |
| name        | string | 否    | 新 Template 名称；不传时使用源名称加 ` Copy`。 |
| description | string | 否    | 新 Template 描述；不传时沿用源描述。          |

## 示例请求

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/templates/tmpl_support/clone' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Support assistant copy",
  "description": "Cloned from Support assistant"
}'
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "type": "template",
  "id": "tmpl_019eYYYY",
  "name": "Support assistant copy",
  "description": "Cloned from Support assistant",
  "status": "active",
  "model": "ultimate",
  "system": "You are a helpful support assistant.",
  "tools": [],
  "mcp_servers": [],
  "skills": [],
  "environment_id": "env_support",
  "vault_ids": [
    "vault_crm"
  ],
  "files": {},
  "environment_variables": {
    "BASE_MODE": "support"
  },
  "metadata": {},
  "created_at": "2026-06-18T10:31:00Z",
  "updated_at": "2026-06-18T10:31:00Z"
}
```

## 响应字段

| 字段  | 类型     | 说明                |
| --- | ------ | ----------------- |
| 返回值 | object | 新创建的 Template 对象。 |

## 错误

| HTTP | Type                    | Code                      | 触发条件              |
| ---- | ----------------------- | ------------------------- | ----------------- |
| 400  | `invalid_request_error` | -                         | 克隆请求不合法。          |
| 404  | `not_found_error`       | -                         | 源 Template 不存在。   |
| 409  | `conflict_error`        | -                         | 新 Template 名称已存在。 |
| 401  | `authentication_error`  | `authentication_required` | PAT 无效或已过期。       |

## 注意事项

* 克隆会生成新的 Template ID。
* 克隆不会复制 Identity Config 记录。

## 相关

<CardGroup cols={2}>
  <Card title="创建 Template" icon="plus" href="/cloud-agents/api/forward/templates/create" />

  <Card title="更新 Template" icon="pencil" href="/cloud-agents/api/forward/templates/update" />
</CardGroup>
