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

# アイデンティティ構成を作成または更新する

> 1 つの Identity と Template に対する Identity Config を作成または更新します。

`POST /api/v1/forward/identities/{identity_id}/templates/{template_id}/config`

config が存在しない場合は作成し、存在する場合は既存のアクティブな config を更新します。Identity Config は Template のベースラインに対するユーザーレベルのオーバーライドです。

## Headers

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

## Path parameters

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

## Body parameters

| Parameter         | Type   | Required | Description                       |
| ----------------- | ------ | -------- | --------------------------------- |
| `name`            | string | No       | Config の表示名。                      |
| `identity_config` | object | Yes      | ユーザーレベルのオーバーライド構成。                |
| `metadata`        | object | No       | カスタムメタデータ。指定した場合は既存のメタデータを置き換えます。 |

## Identity config object

`identity_config` は保存されるユーザーレベルのオーバーライド DSL です。これは Get Effective Config が返すコンパイル済みのランタイム構成ではありません。

| Field                            | Internal target | Description                                                                                                   |
| -------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------- |
| `system`                         | Agent           | システムプロンプトのオーバーライドまたは追加ルール。                                                                                    |
| `model`                          | Agent           | モデルのオーバーライド。                                                                                                  |
| `tools`                          | Agent           | ツール名をキーとする組み込みツールのオーバーライド。                                                                                    |
| `mcp_servers`                    | Agent           | MCP サーバー名をキーとする MCP サーバーのオーバーライド。                                                                             |
| `skills`                         | Agent           | Skill ID をキーとする Skill のオーバーライド。                                                                               |
| `toolsets`                       | Agent           | 主に MCP ツールセットや組み込みツールグループを対象とする、ツールセットレベルのオーバーライド。                                                            |
| `agent_metadata`                 | Agent           | コンパイルされた agent メタデータにマージされるメタデータ。                                                                             |
| `vaults`                         | Session         | Vault ID をキーとする Vault リソースのオーバーライド。                                                                           |
| `files`                          | Session         | File ID をキーとする File リソースのオーバーライド。Forward が `mount_path` を注入するため、呼び出し元はここで指定しません。                              |
| `environment` / `environment_id` | Unsupported     | Identity Config は Template の environment をオーバーライドできません。これらのフィールドを含むリクエストは `400 invalid_request_error` で失敗します。 |

## Update semantics

| Request shape       | Semantics                            |
| ------------------- | ------------------------------------ |
| フィールドが省略されている       | 既存の値を保持します。                          |
| フィールドが非 null 値で存在する | そのフィールドを更新します。                       |
| フィールドが `null` で存在する | 現在の Identity Config からそのフィールドを削除します。 |
| `metadata` が省略されている | 既存のメタデータを保持します。                      |
| `metadata` オブジェクト   | 既存のメタデータを置き換えます。                     |
| `metadata` `null`   | メタデータをクリアします。                        |

## Resource map semantics

`skills`、`vaults`、`files` はリソース ID をマップキーとして使用します。マップ項目の内部に `skill_id`、`vault_id`、`file_id`、`id`、`resource_id` を含めないでください。これらのランタイムフィールドは、Forward がコンパイルした Effective Config にのみ現れます。

| Map item value         | Semantics                                 |
| ---------------------- | ----------------------------------------- |
| `{ "enabled": true }`  | リソースを明示的に有効化またはオーバーライドします。                |
| `{ "enabled": false }` | Template のベースラインに存在していても、リソースを明示的に無効化します。 |
| 項目が省略されている             | Template のベースラインを継承します。                   |
| 項目の値が `null`           | このオーバーライドを削除し、Template の継承を復元します。         |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/identities/idn_019eabc123/templates/tmpl_support/config' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "CRM profile",
    "identity_config": {
      "system": {
        "mode": "append",
        "content": "Prefer CRM data when answering."
      },
      "skills": {
        "skill_customer_reply": {
          "enabled": true,
          "type": "custom",
          "version": "1"
        },
        "skill_marketing_copy": {
          "enabled": false
        }
      },
      "mcp_servers": {
        "mcp_crm": {
          "enabled": true,
          "type": "http",
          "url": "https://crm.example.com/mcp"
        }
      },
      "tools": {
        "Read": { "enabled": true },
        "Grep": { "enabled": true },
        "WebSearch": { "enabled": true }
      },
      "vaults": {
        "vault_crm": { "enabled": true }
      },
      "files": {
        "file_019eXXXX": { "enabled": true }
      }
    },
    "metadata": {}
  }'
```

## Example response

**HTTP 200 OK**

```json theme={null}
{
  "type": "config",
  "identity_id": "idn_019eabc123",
  "template_id": "tmpl_support",
  "name": "CRM profile",
  "status": "active",
  "effective_hash": "sha256:...",
  "created_at": "2026-06-18T10:00:00Z",
  "updated_at": "2026-06-18T10:00:00Z"
}
```

## Response fields

| Field            | Type   | Description          |
| ---------------- | ------ | -------------------- |
| `type`           | string | 常に `config`。         |
| `identity_id`    | string | Forward Identity ID。 |
| `template_id`    | string | Forward Template ID。 |
| `name`           | string | Config の表示名。         |
| `status`         | string | Config のステータス。       |
| `effective_hash` | string | コンパイルされた有効な構成のハッシュ。  |
| `created_at`     | string | 作成タイムスタンプ。           |
| `updated_at`     | string | 更新タイムスタンプ。           |

## Errors

| HTTP | Type                    | Trigger                                                      |
| ---- | ----------------------- | ------------------------------------------------------------ |
| 400  | `invalid_request_error` | config フィールドが無効、サポートされていない environment のオーバーライド、または無効なボディです。 |
| 401  | `authentication_error`  | PAT が無効または期限切れです。                                            |
| 404  | `not_found_error`       | Identity、Template、Skill、Vault、または File が存在しません。              |
| 409  | `conflict_error`        | config の状態が競合しています。                                          |

## Notes

* 省略された config フィールドは変更されません。
* フィールドを `null` に設定すると、現在の Identity Config からそのフィールドが削除されます。
* リソースマップは、そのリソース ID をマップキーとして使用します。1 つのリソースの継承を復元するには、そのマップエントリを `null` に設定します。
* Identity Config は `environment_id` のオーバーライドをサポートしていません。

## Related

<CardGroup cols={2}>
  <Card title="アイデンティティ構成を取得する" icon="file-lines" href="/cloud-agents/api/forward/identities/get-config" />

  <Card title="有効な構成を取得する" icon="layer-group" href="/cloud-agents/api/forward/identities/effective" />
</CardGroup>
