> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# グループの作成

> 関連するサブスクリプション商品を整理するための商品グループを作成する

関連するサブスクリプション商品を整理するための商品グループを作成します。

```
POST /v1/actions/subscription-product-group/create-group
```

**認証：** API Key

## リクエストボディ

| フィールド         | 型         | 必須  | 説明                                   |
| ------------- | --------- | --- | ------------------------------------ |
| `storeId`     | string    | Yes | Store ID（`STO_xxx` フォーマット）           |
| `name`        | string    | Yes | グループ名（ストア + 環境ごとに一意）                 |
| `description` | string    | No  | グループの説明                              |
| `rules`       | object    | No  | グループルール（`{ sharedTrial: boolean }`）  |
| `productIds`  | string\[] | No  | 含めるサブスクリプション商品 ID（`PROD_xxx` フォーマット） |

## リクエスト例

<CodeGroup>
  ```typescript SDK theme={"system"}
  const { group } = await client.subscriptionProductGroups.create({
    storeId: "STO_2D5F8G3H1K4M6N9P",
    name: "Pricing Plans",
    description: "Free, Pro, and Enterprise tiers",
    rules: { sharedTrial: true },
    productIds: [
      "PROD_3F7H2J5L8N1Q4S6U",
      "PROD_8B4D6F9H2K5M7P1R",
      "PROD_1C3E5G7J0L2N4Q6S",
    ],
  });
  ```

  ```bash cURL theme={"system"}
  curl -X POST https://api.waffo.ai/v1/actions/subscription-product-group/create-group \
    -H "Content-Type: application/json" \
    -H "X-Merchant-Id: MER_7K3M9P2R5T8W1Y4Z" \
    -H "X-Timestamp: 2026-03-30T10:00:00Z" \
    -H "X-Signature: BASE64_RSA_SIGNATURE" \
    -d '{
      "storeId": "STO_2D5F8G3H1K4M6N9P",
      "name": "Pricing Plans",
      "description": "Free, Pro, and Enterprise tiers",
      "rules": { "sharedTrial": true },
      "productIds": [
        "PROD_3F7H2J5L8N1Q4S6U",
        "PROD_8B4D6F9H2K5M7P1R",
        "PROD_1C3E5G7J0L2N4Q6S"
      ]
    }'
  ```

  ```python Python theme={"system"}
  body = {
      "storeId": "STO_2D5F8G3H1K4M6N9P",
      "name": "Pricing Plans",
      "description": "Free, Pro, and Enterprise tiers",
      "rules": {"sharedTrial": True},
      "productIds": [
          "PROD_3F7H2J5L8N1Q4S6U",
          "PROD_8B4D6F9H2K5M7P1R",
          "PROD_1C3E5G7J0L2N4Q6S",
      ],
  }

  response = requests.post(
      "https://api.waffo.ai/v1/actions/subscription-product-group/create-group",
      json=body,
      headers=sign_request("POST", "/v1/actions/subscription-product-group/create-group", body),
  )
  group = response.json()["data"]["group"]
  ```
</CodeGroup>

## 成功レスポンス (200)

```json theme={"system"}
{
  "data": {
    "group": {
      "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
      "storeId": "STO_2D5F8G3H1K4M6N9P",
      "name": "Pricing Plans",
      "description": "Free, Pro, and Enterprise tiers",
      "rules": { "sharedTrial": true },
      "productIds": [
        "PROD_3F7H2J5L8N1Q4S6U",
        "PROD_8B4D6F9H2K5M7P1R",
        "PROD_1C3E5G7J0L2N4Q6S"
      ],
      "environment": "test",
      "createdAt": "2026-03-30T10:30:00.000Z",
      "updatedAt": "2026-03-30T10:30:00.000Z"
    }
  }
}
```

## エラー

> **リトライポリシー**：4xx は一切リトライしない — リクエストを修正してから再送信。5xx は指数バックオフでリトライ（5s 開始、最大 3 回）。

| ステータス | `errors[0].message`                                                            | 意味                                              | 推奨処理                       |
| ----- | ------------------------------------------------------------------------------ | ----------------------------------------------- | -------------------------- |
| 400   | `Missing or invalid header: x-context-environment`                             | environment ヘッダーが欠落、または `test` / `prod` 以外      | ヘッダーを修正して再送信               |
| 400   | `Missing required fields: storeId, name`                                       | 必須フィールド欠落                                       | フィールドを追加して再送信              |
| 400   | `Expected format: STO_xxx, got "..."` / `Expected format: PROD_xxx, got "..."` | `storeId` または `productIds` の Short ID をデコードできない | ID を修正して再送信                |
| 500   | `Internal server error`                                                        | 内部エラーまたは一時的な下流障害                                | 指数バックオフでリトライ（5s 開始、最大 3 回） |
