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

# リソースを登録する

> 既存のリソースを Forward Resource として登録します。

`POST /api/v1/forward/resources/registry`

既存のリソースを ID で登録します。このエンドポイントは upsert セマンティクスを持ちます。初回登録では `201 Created` を返し、以降の登録による更新では `200 OK` を返します。

## Headers

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

## Body parameters

| Parameter     | Type   | Required | Description                                             |
| ------------- | ------ | -------- | ------------------------------------------------------- |
| `type`        | string | Yes      | リソースタイプ。サポートされる値: `skill`、`file`、`vault`、`environment`。 |
| `resource`    | object | Yes      | リソースオブジェクト。`resource.id` のみが使用されます。                     |
| `resource.id` | string | Yes      | リソース ID(`skill_...` や `file_...` など)。                   |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/resources/registry' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "skill",
    "resource": {
      "id": "skill_xxx"
    }
  }'
```

## Example response

**HTTP 201 Created**

```json theme={null}
{
  "id": "skill_xxx",
  "type": "skill"
}
```

## Response fields

| Field  | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| `id`   | string | Forward Resource ID。リソース ID と直接一致します。 |
| `type` | string | リソースタイプ。                              |

## Errors

| HTTP | Type                    | Trigger                                             |
| ---- | ----------------------- | --------------------------------------------------- |
| 400  | `invalid_request_error` | `type` が欠落またはサポート対象外、`resource.id` が欠落、またはボディが不正です。 |
| 401  | `authentication_error`  | PAT が無効または期限切れです。                                   |
| 403  | `permission_error`      | 呼び出し元がリソースにアクセスできません。                               |
| 404  | `not_found_error`       | リソースが存在しない、または宣言された `type` が実際のリソースタイプと一致しません。      |

## Notes

* Forward に登録する前に、リソース API を通じてリソースを作成または更新してください。

## Related

<CardGroup cols={2}>
  <Card title="リソース一覧を取得する" icon="list" href="/cloud-agents/api/forward/resources/list" />

  <Card title="テンプレートを作成する" icon="plus" href="/cloud-agents/api/forward/templates/create" />
</CardGroup>
