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

**認証：** API Key（owner または admin ロールが必要）

<Note>
  本エンドポイントは Webhook 設定を管理しません。リクエストボディに `webhookSettings` フィールドが含まれている場合、そのフィールドは黙って無視され、レスポンスのトップレベルに `warnings` 配列が付加されます。他のフィールドは通常どおり更新され、200 が返されます。Webhook の設定は [`add-webhook`](/ja/api-reference/endpoints/webhooks/add-webhook)、[`update-webhook`](/ja/api-reference/endpoints/webhooks/update-webhook)、[`remove-webhook`](/ja/api-reference/endpoints/webhooks/remove-webhook) を使用し、一覧取得は GraphQL `Store.storeWebhooks` を利用してください。
</Note>

## リクエストボディ

| フィールド                  | 型                | 必須  | 説明                                  |
| ---------------------- | ---------------- | --- | ----------------------------------- |
| `id`                   | string           | Yes | Store ID（Short ID フォーマット `STO_xxx`） |
| `name`                 | string           | No  | 更新後のストア名（1-48 文字）                   |
| `status`               | string           | No  | `active`、`inactive`、または `suspended` |
| `logo`                 | string \| null   | No  | ストアロゴ URL（`null` で削除）               |
| `supportEmail`         | `string \| null` | No  | ストアサポートメール（`null` で削除）              |
| `website`              | `string \| null` | No  | ストア Web サイト URL（`null` で削除）         |
| `notificationSettings` | object \| null   | No  | 通知設定（`null` で削除）                    |
| `checkoutSettings`     | object \| null   | No  | チェックアウトテーマ設定（`null` で削除）            |

## 通知設定

書き込み権限により 2 グループに分かれます：

**マーチャント書き込み可能**（✅ このエンドポイントで受け付け）：

| フィールド                          | 型       | デフォルト  | 説明                                         |
| ------------------------------ | ------- | ------ | ------------------------------------------ |
| `notifyNewOrders`              | boolean | `true` | 新規注文をマーチャントに通知                             |
| `notifyNewSubscriptions`       | boolean | `true` | 新規サブスクリプションをマーチャントに通知                      |
| `notifySubscriptionCanceled`   | boolean | `true` | サブスクリプションキャンセル（ユーザー解約、アクセス期間内）をマーチャントに通知   |
| `notifySubscriptionEnded`      | boolean | `true` | サブスクリプション終了時にマーチャントに通知                     |
| `notifySubscriptionPastDue`    | boolean | `true` | サブスクリプションが past\_due（支払失敗）になった際にマーチャントに通知  |
| `notifySubscriptionRenewed`    | boolean | `true` | サブスクリプション更新成功時にマーチャントに通知                   |
| `notifySubscriptionUncanceled` | boolean | `true` | キャンセル後に復帰した際にマーチャントに通知                     |
| `notifySubscriptionUpdated`    | boolean | `true` | サブスクリプションのプラン変更時にマーチャントに通知（forward-compat） |
| `notifyChargeback`             | boolean | `true` | チャージバック発生時にマーチャントに通知（forward-compat）       |

**プラットフォーム管理**（🔒 マーチャント API では読み取り専用；PANCAKE プラットフォームが管理）：

| フィールド                           | 型       | デフォルト  | 説明                           |
| ------------------------------- | ------- | ------ | ---------------------------- |
| `emailOrderConfirmation`        | boolean | `true` | 注文確認時にメールを送信                 |
| `emailSubscriptionConfirmation` | boolean | `true` | サブスクリプション作成時にメールを送信          |
| `emailSubscriptionCycled`       | boolean | `true` | サブスクリプション更新時にメールを送信          |
| `emailSubscriptionCanceled`     | boolean | `true` | サブスクリプションキャンセル時にメールを送信       |
| `emailSubscriptionRevoked`      | boolean | `true` | サブスクリプション失効時にメールを送信          |
| `emailSubscriptionPastDue`      | boolean | `true` | サブスクリプション滞納時にメールを送信          |
| `emailTrialStarted`             | boolean | `true` | 無料トライアル開始時にメールを送信            |
| `emailTrialEnding`              | boolean | `true` | トライアル終了前にリマインダーメールを送信        |
| `emailUpcomingCharge`           | boolean | `true` | サブスクリプションの次回請求前にリマインダーメールを送信 |

<Note>
  `notificationSettings` ペイロードにプラットフォーム管理フィールド（`email*`、またはレガシーの `notifyPayoutCompleted` / `notifyPayoutFailed` — 出金結果メールは常に配信され、トグルはありません）が含まれる場合、サーバーは静かに破棄し、`200` レスポンスの `warnings[]` に破棄されたキーを返します。customer メールの toggle 変更は PANCAKE プラットフォームサポートまでご連絡ください。
</Note>

## チェックアウト設定

| フィールド             | 型       | 説明                  |
| ----------------- | ------- | ------------------- |
| `defaultDarkMode` | boolean | デフォルトでダークモードにするかどうか |
| `light`           | object  | ライトテーマ設定（以下参照）      |
| `dark`            | object  | ダークテーマ設定（以下参照）      |

**チェックアウトテーマ設定**（`light` と `dark` の両方に適用）:

| フィールド                     | 型              | 説明                |
| ------------------------- | -------------- | ----------------- |
| `checkoutLogo`            | string \| null | チェックアウトページのロゴ URL |
| `checkoutColorPrimary`    | string         | プライマリカラー（16 進数）   |
| `checkoutColorBackground` | string         | 背景色（16 進数）        |
| `checkoutColorCard`       | string         | カード/パネル色（16 進数）   |
| `checkoutColorText`       | string         | テキスト色（16 進数）      |
| `checkoutBorderRadius`    | string         | ボーダー半径（CSS 値）     |

## 部分更新セマンティクス

2 つの settings オブジェクトはどちらも部分更新をサポートしています。各サブフィールドには 3 つの値セマンティクスがあります：

| 値              | 動作        | 例                                                   |
| -------------- | --------- | --------------------------------------------------- |
| 省略（JSON に含めない） | 既存の値を保持   | `notifyNewOrders` のみ送信、他の通知フラグは変更なし                 |
| `null`         | フィールドをクリア | `"checkoutLogo": null` でチェックアウトロゴを削除                |
| 実際の値           | 作成または更新   | `"checkoutColorPrimary": "#FF6600"` で新しいプライマリカラーを設定 |

オブジェクト全体を `null` に設定すると（例：`"notificationSettings": null`）、その設定グループのすべてのフィールドがクリアされます。

## リクエスト例

<CodeGroup>
  ```typescript SDK theme={"system"}
  import { WaffoPancake, EntityStatus } from "@waffo/pancake-ts";

  const client = new WaffoPancake({
    merchantId: process.env.WAFFO_MERCHANT_ID!,
    privateKey: process.env.WAFFO_PRIVATE_KEY!,
  });

  const { store } = await client.stores.update({
    id: "STO_2aUyqjCzEIiEcYMKj7TZtw",
    name: "Updated Store Name",

    // マーチャント書き込み可能な通知 toggle（B 類）のみ送信できます。
    // customer 向けメール toggle（emailOrderConfirmation 等の A 類）は
    // PANCAKE プラットフォームが管理しているため、ここで送信すると
    // サーバー側で静かに破棄され、200 warning が返ります。
    notificationSettings: {
      notifyNewOrders: true,
      notifyNewSubscriptions: false,
    },
  });
  ```

  ```typescript TypeScript (fetch) theme={"system"}
  // Uses callApi() helper from authentication.mdx
  const result = await callApi("POST", "/v1/actions/store/update-store", {
    id: "STO_2aUyqjCzEIiEcYMKj7TZtw",
    name: "Updated Store Name",

    notificationSettings: {
      notifyNewSubscriptions: false,
    },
  });
  console.log(result.data.store.name); // => "Updated Store Name"
  ```

  ```java Java theme={"system"}
  // Uses callApi() helper from authentication.mdx
  String body = """
      {
        "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
        "name": "Updated Store Name",

        "notificationSettings": {
          "notifyNewSubscriptions": false
        }
      }""";

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

  ```python Python theme={"system"}
  # Uses call_api() helper from authentication.mdx
  result = call_api("POST", "/v1/actions/store/update-store", {
      "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Updated Store Name",

      "notificationSettings": {
          "notifyNewSubscriptions": False,
      },
  })
  store = result["data"]["store"]
  print(store["name"])  # => "Updated Store Name"
  ```

  ```go Go theme={"system"}
  // Uses callAPI() helper from authentication.mdx
  body := map[string]interface{}{
      "id":   "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Updated Store Name",

      "notificationSettings": map[string]interface{}{
          "notifyNewSubscriptions": false,
      },
  }
  result, err := callAPI("POST", "/v1/actions/store/update-store", 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": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Updated Store Name",

      "notificationSettings": {
          "notifyNewSubscriptions": false
      }
  });
  let result = call_api("POST", "/v1/actions/store/update-store", &body).await?;
  println!("{}", result);
  ```

  ```c C theme={"system"}
  /* Uses call_api() helper from authentication.mdx */
  const char *body =
      "{\"id\":\"STO_2aUyqjCzEIiEcYMKj7TZtw\","
      "\"name\":\"Updated Store Name\","
      "\"notificationSettings\":{\"notifyNewSubscriptions\":false}}";
  char *response = call_api("POST", "/v1/actions/store/update-store", body);
  printf("%s\n", response);
  free(response);
  ```

  ```cpp C++ theme={"system"}
  // Uses callApi() helper from authentication.mdx
  std::string body = R"({
    "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
    "name": "Updated Store Name",
    "notificationSettings": {
      "notifyNewSubscriptions": false
    }
  })";
  std::string response = callApi("POST", "/v1/actions/store/update-store", body);
  std::cout << response << std::endl;
  ```

  ```bash cURL theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw","name":"Updated Store Name","notificationSettings":{"notifyNewSubscriptions":false}}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/update-store
  $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/store/update-store" \
    -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":"STO_2aUyqjCzEIiEcYMKj7TZtw","name":"Updated Store Name","notificationSettings":{"notifyNewSubscriptions":false}}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/update-store
  $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/store/update-store" \
    --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": {
    "store": {
      "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
      "name": "Updated Store Name",
      "status": "active",
      "logo": null,
      "slug": "my-digital-store-a1b2c3",
      "prodEnabled": false,
      "notificationSettings": {
        "emailOrderConfirmation": true,
        "emailSubscriptionConfirmation": true,
        "emailSubscriptionCycled": true,
        "emailSubscriptionCanceled": true,
        "emailSubscriptionRevoked": true,
        "emailSubscriptionPastDue": true,
        "emailTrialStarted": true,
        "emailTrialEnding": true,
        "emailUpcomingCharge": true,
        "notifyNewOrders": true,
        "notifyNewSubscriptions": false,
        "notifySubscriptionCanceled": true,
        "notifySubscriptionEnded": true,
        "notifySubscriptionPastDue": true,
        "notifySubscriptionRenewed": true,
        "notifySubscriptionUncanceled": true,
        "notifySubscriptionUpdated": true,
        "notifyChargeback": true
      },
      "checkoutSettings": {
        "defaultDarkMode": false,
        "light": {
          "checkoutLogo": null,
          "checkoutColorPrimary": "#000000",
          "checkoutColorBackground": "#FFFFFF",
          "checkoutColorCard": "#F5F5F5",
          "checkoutColorText": "#1A1A1A",
          "checkoutBorderRadius": "8px"
        },
        "dark": {
          "checkoutLogo": null,
          "checkoutColorPrimary": "#FFFFFF",
          "checkoutColorBackground": "#1A1A1A",
          "checkoutColorCard": "#2A2A2A",
          "checkoutColorText": "#F5F5F5",
          "checkoutBorderRadius": "8px"
        }
      },
      "deletedAt": null,
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-15T11:00:00.000Z"
    }
  }
}
```

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

[ストアの作成レスポンスフィールド](/ja/api-reference/endpoints/stores/create-store#response-fields)と同じです。

## webhookSettings 互換性警告

リクエストボディに `webhookSettings` フィールドが含まれている場合、そのフィールドは黙って無視され、レスポンスのトップレベルに `warnings` 配列が含まれます。`data.store` オブジェクトには影響しません。

```json theme={"system"}
{
  "data": { "store": { "...": "..." } },
  "warnings": [
    {
      "message": "webhookSettings is no longer accepted on update-store; the field was ignored.",
      "layer": "store",
      "aiHint": "AI assistant: 'webhookSettings' is permanently removed (BREAKING 2026-05). Do not retry with this field. SDK users: upgrade to @waffo/pancake-ts >= 0.6.0 and call client.webhooks.add / update / remove instead of client.stores.update({ webhookSettings }). Direct API users: POST /api/actions/store/add-webhook to create a webhook, /update-webhook to modify, /remove-webhook to delete. Query the webhook list via GraphQL Store.storeWebhooks field, not via this endpoint."
    }
  ]
}
```

## エラー

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

| ステータス | `errors[0].message`                                     | 意味                                    | 推奨処理                                      |
| ----- | ------------------------------------------------------- | ------------------------------------- | ----------------------------------------- |
| 400   | `Missing merchantId in request context`                 | API Key がマーチャントコンテキストを解決できなかった        | **リトライしない**。API Key 設定を確認。                |
| 400   | `Missing required field: id`                            | リクエストボディに `id` が含まれていない               | 入力を修正して再送信。                               |
| 400   | `Expected format: STO_xxx, got "<value>"`               | `id` が有効な Store Short ID ではない         | `id` を修正して再送信。                            |
| 400   | `Store name cannot be empty or contain only whitespace` | `trim()` 後の `name` が空                 | `name` を修正して再送信。                          |
| 400   | `Store name cannot exceed 48 characters`                | `name` が 48 文字を超える                    | `name` を短縮して再送信。                          |
| 400   | `Invalid status, must be active, inactive or suspended` | `status` が許可された列挙値ではない                | `active`、`inactive`、`suspended` のいずれかを使用。 |
| 400   | `Invalid logo: must be a string or null`                | `logo` が文字列でも `null` でもない             | 文字列 URL もしくは `null`（クリア）を渡す。              |
| 403   | `Not authorized to update this store`                   | 当該ストアでの呼び出し元ロールが `owner`/`admin` ではない | **リトライしない**。権限のあるマーチャントを使用。               |
| 404   | `Store not found`                                       | 当該マーチャント下に該当ストア ID が存在しない             | **リトライしない**。`id` を確認。                     |
