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

# Update a template

> Forward テンプレートを ID で更新します。

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

変更可能なテンプレートフィールドを更新します。リクエストから省略されたフィールドは変更されません。`tools`、`mcp_servers`、`skills` などの配列フィールドは、指定された場合は全体が置き換えられます。

## Headers

| Header            | Required | Description             |
| ----------------- | -------- | ----------------------- |
| `Authorization`   | Yes      | `Bearer <PAT>`          |
| `Content-Type`    | Yes      | `application/json`      |
| `Idempotency-Key` | No       | 安全でないリクエストに対する任意の冪等性キー。 |

## Path parameters

| Parameter     | Type   | Required | Description            |
| ------------- | ------ | -------- | ---------------------- |
| `template_id` | string | Yes      | Forward の Template ID。 |

## Body parameters

| Parameter               | Type                   | Required | Description                                                |
| ----------------------- | ---------------------- | -------- | ---------------------------------------------------------- |
| `name`                  | string                 | No       | 新しいテンプレート名。                                                |
| `description`           | string                 | No       | 新しいテンプレートの説明。                                              |
| `model`                 | string                 | No       | 新しいモデル識別子。                                                 |
| `system`                | string                 | No       | 新しいシステムプロンプト。                                              |
| `tools`                 | array                  | No       | ツール設定のリストを置き換えます。                                          |
| `mcp_servers`           | array                  | No       | MCP サーバーのリストを置き換えます。                                       |
| `skills`                | array                  | No       | Skill のバインディングリストを置き換えます。                                  |
| `multiagent`            | object                 | No       | Managed Agents の設定を置き換えます。                                 |
| `environment_id`        | string\|null           | No       | デフォルトの Environment ID を置き換えます。`null` または空文字列を指定するとクリアされます。 |
| `vault_ids`             | array\|null            | No       | デフォルトの Vault ID を置き換えます。`null` を指定するとリストがクリアされます。          |
| `files`                 | object\|null           | No       | デフォルトのファイルリソースを置き換えます。`null` を指定するとマップがクリアされます。            |
| `environment_variables` | object \| string\|null | No       | デフォルトのセッション環境変数を置き換えます。`null` を指定するとクリアされます。               |
| `metadata`              | object                 | No       | カスタムメタデータをマージして更新します。                                      |

## Nested configuration objects

`tools`、`mcp_servers`、`skills` は配列フィールドです。更新リクエストで指定された場合、各配列は以前の配列を全体として置き換えます。

### File resources

`files` は File ID をキーとするマップです。各項目の内部に `file_id`、`id`、`resource_id` を含めないでください。Forward は Session の作成時に `mount_path` を注入します。

| Field     | Type    | Required | Description                                                    |
| --------- | ------- | -------- | -------------------------------------------------------------- |
| `enabled` | boolean | No       | デフォルトは `true`。`false` にすると、Identity Config で継承されたファイルが無効になります。 |

### Tools array

各 `tools[]` の項目は `type` によって選択されます。

| Field              | Type   | Applies to                              | Description                                                |
| ------------------ | ------ | --------------------------------------- | ---------------------------------------------------------- |
| `type`             | string | All                                     | 必須。`agent_toolset_20260401`、`mcp_toolset`、または `custom`。    |
| `enabled_tools`    | array  | `agent_toolset_20260401`                | 便宜的な許可リスト。空でないリストを指定すると、これらの組み込みツールのみが有効になります。             |
| `disallowed_tools` | array  | `agent_toolset_20260401`                | 便宜的な拒否リスト。無効化されたツール設定にコンパイルされます。                           |
| `configs`          | array  | `agent_toolset_20260401`, `mcp_toolset` | ツールごとの有効化と権限ポリシー。                                          |
| `mcp_server_name`  | string | `mcp_toolset`                           | 必須。`mcp_servers[].name` のいずれかの項目と一致する必要があります。              |
| `name`             | string | `custom`                                | 必須のカスタムツール名。組み込みツールと競合してはいけません。                            |
| `description`      | string | `custom`                                | 必須のカスタムツールの説明。                                             |
| `input_schema`     | object | `custom`                                | 必須の JSON Schema。`input_schema.type` は `object` である必要があります。 |

組み込みツール名は `Bash`、`Read`、`Write`、`Edit`、`Glob`、`Grep`、`WebFetch`、`WebSearch`、`DeliverArtifacts` です。

### Tool config

`tools[].configs[]` の項目はこの形式を使用します。

| Field               | Type    | Required | Description                                                             |
| ------------------- | ------- | -------- | ----------------------------------------------------------------------- |
| `name`              | string  | Yes      | ツール名。`agent_toolset_20260401` の場合は組み込みツール名、`mcp_toolset` の場合は MCP ツール名。 |
| `enabled`           | boolean | No       | `false` にするとツールを非表示にして拒否します。`true` にすると明示的に有効化します。                      |
| `permission_policy` | object  | No       | 実行時の権限の挙動。                                                              |

### Permission policy

| Field  | Type   | Required | Description                                    |
| ------ | ------ | -------- | ---------------------------------------------- |
| `type` | string | Yes      | `always_allow`、`always_ask`、または `always_deny`。 |

### MCP servers

| Field  | Type   | Required | Description                                                     |
| ------ | ------ | -------- | --------------------------------------------------------------- |
| `type` | string | No       | 現在は `http` のみ。省略された値は Effective Config で HTTP MCP サーバーとして扱われます。 |
| `name` | string | Yes      | Template 内で一意の MCP サーバー名。`tools[].mcp_server_name` から参照されます。    |
| `url`  | string | Yes      | Streamable HTTP MCP エンドポイントの URL。                               |

### Skills

| Field      | Type    | Required | Description                                                      |
| ---------- | ------- | -------- | ---------------------------------------------------------------- |
| `type`     | string  | Yes      | `custom` または `qoder`。                                            |
| `skill_id` | string  | Yes      | Skill ID。                                                        |
| `version`  | string  | No       | Skill のバージョン。省略した場合は最新バージョンが使用されます。                              |
| `enabled`  | boolean | No       | デフォルトは `true`。`false` にすると、コンパイルされたエージェント設定にその Skill が含まれなくなります。 |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/templates/tmpl_support' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Support assistant v2",
    "environment_id": "env_support_v2",
    "vault_ids": ["vault_crm", "vault_billing"],
    "environment_variables": {
      "BASE_MODE": "support_v2"
    }
  }'
```

## Example response

**HTTP 200 OK**

```json theme={null}
{
  "type": "template",
  "id": "tmpl_support",
  "name": "Support assistant v2",
  "description": "Handles pre-sales and after-sales support",
  "status": "active",
  "model": "ultimate",
  "system": "You are a helpful support assistant.",
  "tools": [],
  "mcp_servers": [],
  "skills": [],
  "multiagent": null,
  "environment_id": "env_support_v2",
  "vault_ids": ["vault_crm", "vault_billing"],
  "files": {},
  "environment_variables": {
    "BASE_MODE": "support_v2"
  },
  "metadata": {},
  "created_at": "2026-06-18T10:00:00Z",
  "updated_at": "2026-06-18T10:30:00Z"
}
```

## Response fields

更新された Template オブジェクトを返します。

## Errors

| HTTP | Type                    | Trigger                          |
| ---- | ----------------------- | -------------------------------- |
| 400  | `invalid_request_error` | リクエストボディが不正、またはサポートされていないフィールド値。 |
| 401  | `authentication_error`  | PAT が無効または期限切れ。                  |
| 404  | `not_found_error`       | テンプレートまたは参照されたリソースが存在しない。        |
| 409  | `conflict_error`        | テンプレート名が既に存在する。                  |

## Notes

* アーカイブ済みのテンプレートは更新できません。
* セッションのデフォルト値を更新しても、既存のセッションは変更されません。

## Related

<CardGroup cols={2}>
  <Card title="テンプレートの取得" icon="file-lines" href="/cloud-agents/api/forward/templates/get" />

  <Card title="テンプレートのクローン" icon="copy" href="/cloud-agents/api/forward/templates/clone" />
</CardGroup>
