> ## 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/onetime-product/update-product
```

**認証：** API Key

<Warning>
  商品のステータス（`active`/`inactive`）を変更するには、[ステータスの更新](/api-reference/endpoints/onetime-products/update-status)エンドポイントを使用してください。このエンドポイントはコンテンツの更新のみです。
</Warning>

## リクエストボディ

| フィールド         | 型              | 必須  | 説明                                                                   |
| ------------- | -------------- | --- | -------------------------------------------------------------------- |
| `id`          | string         | Yes | 商品 ID（Short ID フォーマット `PROD_xxx`）                                    |
| `name`        | string         | No  | 更新後の商品名（64 文字以下）                                                     |
| `description` | string \| null | No  | 更新後の説明（`null` または `""` で消去可能）                                        |
| `prices`      | object         | No  | 更新後のマルチ通貨価格マップ                                                       |
| `media`       | array          | No  | 更新後のメディアアイテム                                                         |
| `successUrl`  | string \| null | No  | 更新後のリダイレクト URL（512 文字以下、有効な http(s) URL であること；`null` または `""` で消去可能） |
| `metadata`    | object         | No  | 更新後のカスタムメタデータ                                                        |

`prices` と `media` のオブジェクトフォーマットについては、[商品の作成](/api-reference/endpoints/onetime-products/create-product#price-object-format)を参照してください。

## リクエスト例

<CodeGroup>
  ```typescript SDK theme={"system"}
  const { product } = await client.onetimeProducts.update({
    id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
    name: "Premium Template Pack v2",
    description: "75 premium design templates — expanded collection.",
    prices: {
      USD: { amount: "59.00", taxIncluded: false, taxCategory: TaxCategory.DigitalGoods },
      EUR: { amount: "55.00", taxIncluded: true, taxCategory: TaxCategory.DigitalGoods },
    },
    successUrl: "https://example.com/thank-you",
  });
  ```

  ```typescript TypeScript (fetch) theme={"system"}
  // Uses callApi() helper from authentication.mdx
  const result = await callApi("POST", "/v1/actions/onetime-product/update-product", {
    id: "PROD_3kF9mNpQrStUvWxYz1A2bC",
    name: "Premium Template Pack v2",
    description: "75 premium design templates — expanded collection.",
    prices: {
      USD: { amount: "59.00", taxIncluded: false, taxCategory: "digital_goods" },
      EUR: { amount: "55.00", taxIncluded: true, taxCategory: "digital_goods" },
    },
    successUrl: "https://example.com/thank-you",
  });
  console.log(result.data.product.name); // => "Premium Template Pack v2"
  ```

  ```java Java theme={"system"}
  // Uses callApi() helper from authentication.mdx
  String body = """
      {
        "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
        "name": "Premium Template Pack v2",
        "description": "75 premium design templates — expanded collection.",
        "prices": {
          "USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
          "EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
        },
        "successUrl": "https://example.com/thank-you"
      }""";

  String response = callApi("POST", "/v1/actions/onetime-product/update-product", body);
  System.out.println(response);
  ```

  ```python Python theme={"system"}
  # Uses call_api() helper from authentication.mdx
  result = call_api("POST", "/v1/actions/onetime-product/update-product", {
      "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
      "name": "Premium Template Pack v2",
      "description": "75 premium design templates — expanded collection.",
      "prices": {
          "USD": {"amount": "59.00", "taxIncluded": False, "taxCategory": "digital_goods"},
          "EUR": {"amount": "55.00", "taxIncluded": True, "taxCategory": "digital_goods"},
      },
      "successUrl": "https://example.com/thank-you",
  })
  print(result["data"]["product"]["name"])  # => "Premium Template Pack v2"
  ```

  ```go Go theme={"system"}
  // Uses callAPI() helper from authentication.mdx
  body := map[string]interface{}{
      "id":   "PROD_3kF9mNpQrStUvWxYz1A2bC",
      "name": "Premium Template Pack v2",
      "description": "75 premium design templates — expanded collection.",
      "prices": map[string]interface{}{
          "USD": map[string]interface{}{"amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods"},
          "EUR": map[string]interface{}{"amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods"},
      },
      "successUrl": "https://example.com/thank-you",
  }
  result, err := callAPI("POST", "/v1/actions/onetime-product/update-product", body)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println(string(result))
  ```

  ```rust Rust theme={"system"}
  // Uses call_api() helper from authentication.mdx
  let body = serde_json::json!({
      "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
      "name": "Premium Template Pack v2",
      "description": "75 premium design templates — expanded collection.",
      "prices": {
          "USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
          "EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
      },
      "successUrl": "https://example.com/thank-you"
  });
  let result = call_api("POST", "/v1/actions/onetime-product/update-product", &body).await?;
  println!("{}", result);
  ```

  ```c C theme={"system"}
  /* Uses call_api() helper from authentication.mdx */
  const char *body =
      "{\"id\":\"PROD_3kF9mNpQrStUvWxYz1A2bC\","
      "\"name\":\"Premium Template Pack v2\","
      "\"description\":\"75 premium design templates — expanded collection.\","
      "\"prices\":{\"USD\":{\"amount\":\"59.00\",\"taxIncluded\":false,\"taxCategory\":\"digital_goods\"},"
      "\"EUR\":{\"amount\":\"55.00\",\"taxIncluded\":true,\"taxCategory\":\"digital_goods\"}},"
      "\"successUrl\":\"https://example.com/thank-you\"}";
  char *response = call_api("POST", "/v1/actions/onetime-product/update-product", body);
  printf("%s\n", response);
  free(response);
  ```

  ```cpp C++ theme={"system"}
  // Uses callApi() helper from authentication.mdx
  std::string body = R"({
    "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
    "name": "Premium Template Pack v2",
    "description": "75 premium design templates — expanded collection.",
    "prices": {
      "USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
      "EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
    },
    "successUrl": "https://example.com/thank-you"
  })";
  std::string response = callApi("POST", "/v1/actions/onetime-product/update-product", body);
  std::cout << response << std::endl;
  ```

  ```bash cURL theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{
    "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
    "name": "Premium Template Pack v2",
    "description": "75 premium design templates — expanded collection.",
    "prices": {
      "USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
      "EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
    },
    "successUrl": "https://example.com/thank-you"
  }'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/onetime-product/update-product
  $TIMESTAMP
  $BODY_HASH"

  SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

  curl -X POST "https://api.waffo.ai/v1/actions/onetime-product/update-product" \
    -H "Content-Type: application/json" \
    -H "X-Merchant-Id: $MERCHANT_ID" \
    -H "X-Timestamp: $TIMESTAMP" \
    -H "X-Signature: $SIGNATURE" \
    -d "$BODY"
  ```

  ```bash wget theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{
    "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
    "name": "Premium Template Pack v2",
    "description": "75 premium design templates — expanded collection.",
    "prices": {
      "USD": { "amount": "59.00", "taxIncluded": false, "taxCategory": "digital_goods" },
      "EUR": { "amount": "55.00", "taxIncluded": true, "taxCategory": "digital_goods" }
    },
    "successUrl": "https://example.com/thank-you"
  }'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/onetime-product/update-product
  $TIMESTAMP
  $BODY_HASH"

  SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

  wget -qO- "https://api.waffo.ai/v1/actions/onetime-product/update-product" \
    --header="Content-Type: application/json" \
    --header="X-Merchant-Id: $MERCHANT_ID" \
    --header="X-Timestamp: $TIMESTAMP" \
    --header="X-Signature: $SIGNATURE" \
    --post-data="$BODY"
  ```
</CodeGroup>

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

```json theme={"system"}
{
  "data": {
    "product": {
      "id": "PROD_3kF9mNpQrStUvWxYz1A2bC",
      "storeId": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Premium Template Pack v2",
      "description": "75 premium design templates — expanded collection.",
      "prices": {
        "USD": { "amount": "59.00", "taxCategory": "digital_goods" },
        "EUR": { "amount": "55.00", "taxCategory": "digital_goods" }
      },
      "media": [],
      "successUrl": "https://example.com/thank-you",
      "metadata": {},
      "status": "active",
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-15T11:00:00.000Z"
    }
  }
}
```

## レスポンスフィールド

[商品の作成レスポンス](/api-reference/endpoints/onetime-products/create-product#response-fields)と同じです。

<Note>
  商品バージョンは**イミュータブル**です。既存の注文は元のバージョンを保持します。新規購入は常に最新バージョンを使用します。送信されたコンテンツが現在のバージョンと同一の場合、新しいバージョンは作成されず、既存のバージョンが返されます。
</Note>

## エラー

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

| ステータス | `errors[0].message`                         | 意味                                                          | 推奨処理                                                                                        |
| ----- | ------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| 400   | `Missing required field: id`                | `id` が指定されていません                                             | ボディを修正して再送信                                                                                 |
| 400   | `Invalid ID format`                         | 指定された Short ID をデコードできませんでした                                | `id` のフォーマットを修正して再送信                                                                        |
| 400   | `Invalid currency code`                     | 通貨コードは ISO 4217 に準拠した3文字の大文字である必要があります（例：`USD`、`EUR`、`JPY`） | 有効な ISO 4217 コードを使用して再送信                                                                    |
| 400   | `Invalid amount`                            | 金額は正の数値文字列である必要があります（例：`"9.99"`、`"100"`）                    | 正の数値文字列を使用して再送信                                                                             |
| 400   | `Product X has no version in environment Y` | 商品が対象環境にまだバージョンを持たない（例：`prod` 未公開で更新を試みた）                   | 先に [Publish Product](/api-reference/endpoints/onetime-products/publish-product) で商品を対象環境に公開 |
| 404   | `Product not found`                         | 商品が存在しないかアクセスできません                                          | `id` が現在のマーチャントに属することを確認                                                                    |
| 500   | `Internal server error`                     | サーバ側の予期しない障害                                                | 指数バックオフでリトライ（5s 開始、最大 3 回）                                                                  |
