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

# Create a template

> 今後のセッションのベースラインとなる Forward テンプレートを作成します。

`POST /api/v1/forward/templates`

Forward が Identity に対してセッションを開始する際に使用する、デフォルトのエージェント設定とセッションのデフォルト値を定義するテンプレートを作成します。

## Headers

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

## Body parameters

| Parameter               | Type             | Required | Description                                   |
| ----------------------- | ---------------- | -------- | --------------------------------------------- |
| `name`                  | string           | Yes      | テンプレート名。1〜256 文字で、アカウント内で一意である必要があります。        |
| `model`                 | string           | Yes      | `ultimate` などのモデル識別子。                         |
| `environment_id`        | string           | Yes      | このテンプレートから作成されたセッションで使用されるデフォルトの Environment。 |
| `description`           | string           | No       | テンプレートの説明。最大 2048 文字。                         |
| `system`                | string           | No       | システムプロンプト。最大 100,000 文字。                      |
| `tools`                 | array            | No       | ツール設定のリスト。最大 128 件。                           |
| `mcp_servers`           | array            | No       | MCP サーバー設定のリスト。最大 20 件。                       |
| `skills`                | array            | No       | Skill のバインディングリスト。最大 20 件。                    |
| `multiagent`            | object           | No       | Managed Agents の設定。                           |
| `vault_ids`             | array            | No       | セッションで使用されるデフォルトの Vault ID。                   |
| `files`                 | object           | No       | ファイル ID をキーとするデフォルトのファイルリソース。                 |
| `environment_variables` | object \| string | No       | デフォルトのセッション環境変数。                              |
| `metadata`              | object           | No       | カスタムメタデータ。                                    |

## Nested configuration objects

### 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' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Support assistant",
    "description": "Handles pre-sales and after-sales support",
    "model": "ultimate",
    "system": "You are a helpful support assistant.",
    "tools": [
      {
        "type": "agent_toolset_20260401",
        "configs": [
          { "name": "Read", "enabled": true },
          { "name": "Grep", "enabled": true },
          { "name": "WebSearch", "enabled": true }
        ]
      }
    ],
    "mcp_servers": [],
    "skills": [
      {
        "type": "custom",
        "skill_id": "skill_customer_reply",
        "version": "1",
        "enabled": true
      }
    ],
    "environment_id": "env_support",
    "vault_ids": ["vault_crm"],
    "files": {
      "file_019eXXXX": { "enabled": true }
    },
    "environment_variables": {
      "BASE_MODE": "support"
    },
    "metadata": {}
  }'
```

## Example response

**HTTP 201 Created**

```json theme={null}
{
  "type": "template",
  "id": "tmpl_support",
  "name": "Support assistant",
  "description": "Handles pre-sales and after-sales support",
  "status": "active",
  "model": "ultimate",
  "system": "You are a helpful support assistant.",
  "tools": [
    {
      "type": "agent_toolset_20260401",
      "configs": [
        { "name": "Read", "enabled": true },
        { "name": "Grep", "enabled": true },
        { "name": "WebSearch", "enabled": true }
      ]
    }
  ],
  "mcp_servers": [],
  "skills": [
    {
      "type": "custom",
      "skill_id": "skill_customer_reply",
      "version": "1",
      "enabled": true
    }
  ],
  "multiagent": null,
  "environment_id": "env_support",
  "vault_ids": ["vault_crm"],
  "files": {
    "file_019eXXXX": { "enabled": true }
  },
  "environment_variables": {
    "BASE_MODE": "support"
  },
  "metadata": {},
  "created_at": "2026-06-18T10:00:00Z",
  "updated_at": "2026-06-18T10:00:00Z"
}
```

## Response fields

| Field            | Type   | Description                       |
| ---------------- | ------ | --------------------------------- |
| `type`           | string | 常に `template`。                    |
| `id`             | string | Template ID。                      |
| `status`         | string | `active` または `archived`。          |
| `environment_id` | string | セッションで使用されるデフォルトの Environment ID。 |
| `vault_ids`      | array  | デフォルトの Vault ID。                  |
| `files`          | object | ファイル ID をキーとするデフォルトのファイルリソース設定。   |
| `created_at`     | string | 作成タイムスタンプ。                        |
| `updated_at`     | string | 更新タイムスタンプ。                        |

## Errors

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

## Notes

* `id` は Forward によって生成されます。作成リクエストで Template ID を送信しないでください。
* `files` はファイル ID をキーとするマップです。各ファイル項目の内部に `file_id`、`id`、`resource_id` を含めないでください。
* Forward はセッション作成時にファイルのマウントパスを注入します。

## Related

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

  <Card title="セッションの作成" icon="comment" href="/cloud-agents/api/forward/sessions/create" />
</CardGroup>
