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

# ストアの削除

> ストアを論理削除する（owner のみ）

ストアを論理削除します。ストアデータは保持されますが、アクセスできなくなります。この操作はストアの **owner** のみが実行できます。

```
POST /v1/actions/store/delete-store
```

**認証：** API Key（owner ロールが必要）

## リクエストボディ

| フィールド | 型      | 必須  | 説明                                    |
| ----- | ------ | --- | ------------------------------------- |
| `id`  | string | Yes | 削除するストア ID（Short ID フォーマット `STO_xxx`） |

## リクエスト例

<CodeGroup>
  ```typescript SDK theme={"system"}
  const { store } = await client.stores.delete({
    id: "STO_2aUyqjCzEIiEcYMKj7TZtw",
  });
  console.log(store.deletedAt); // => "2026-01-15T12:00:00.000Z"
  ```

  ```typescript TypeScript (fetch) theme={"system"}
  // Uses callApi() helper from authentication.mdx
  const result = await callApi("POST", "/v1/actions/store/delete-store", {
    id: "STO_2aUyqjCzEIiEcYMKj7TZtw",
  });
  console.log(result.data.store.deletedAt); // => "2026-01-15T12:00:00.000Z"
  ```

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

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

  ```python Python theme={"system"}
  # Uses call_api() helper from authentication.mdx
  result = call_api("POST", "/v1/actions/store/delete-store", {
      "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
  })
  store = result["data"]["store"]
  print(store["deletedAt"])  # => "2026-01-15T12:00:00.000Z"
  ```

  ```go Go theme={"system"}
  // Uses callAPI() helper from authentication.mdx
  body := map[string]interface{}{
      "id": "STO_2aUyqjCzEIiEcYMKj7TZtw",
  }
  result, err := callAPI("POST", "/v1/actions/store/delete-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"
  });
  let result = call_api("POST", "/v1/actions/store/delete-store", &body).await?;
  println!("{}", result);
  ```

  ```c C theme={"system"}
  /* Uses call_api() helper from authentication.mdx */
  const char *body = "{\"id\":\"STO_2aUyqjCzEIiEcYMKj7TZtw\"}";
  char *response = call_api("POST", "/v1/actions/store/delete-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"})";
  std::string response = callApi("POST", "/v1/actions/store/delete-store", body);
  std::cout << response << std::endl;
  ```

  ```bash cURL theme={"system"}
  MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
  TIMESTAMP=$(date +%s)
  BODY='{"id":"STO_2aUyqjCzEIiEcYMKj7TZtw"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/delete-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/delete-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"}'
  BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
  CANONICAL_REQUEST="POST
  /v1/actions/store/delete-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/delete-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": "My Digital Store",
      "status": "active",
      "logo": null,
      "supportEmail": null,
      "website": null,
      "slug": "my-digital-store-a1b2c3",
      "prodEnabled": false,
      "notificationSettings": null,
      "checkoutSettings": null,
      "deletedAt": "2026-01-15T12:00:00.000Z",
      "createdAt": "2026-01-15T10:30:00.000Z",
      "updatedAt": "2026-01-15T12:00:00.000Z"
    }
  }
}
```

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

[ストアの作成レスポンスフィールド](/api-reference/endpoints/stores/create-store#response-fields)と同じです（`deletedAt` が設定されます）。

## エラー

> **リトライポリシー**：4xx は一切リトライしない — リクエストを修正してから再送信。5xx は指数バックオフでリトライ（5s 開始、最大 3 回）。409 はブロッキングリソースを先に解消（AI 呼び出し元は `aiHint` 経由で人間オペレーターへエスカレーション）。

| ステータス | `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` を修正して再送信。                        |
| 403   | `Not authorized to delete this store, only owner can delete`             | 当該ストアでの呼び出し元ロールが `owner` ではない                 | **リトライしない**。`owner` の API Key を使用。    |
| 404   | `Store not found`                                                        | 当該マーチャント下に該当ストア ID が存在しない                     | **リトライしない**。`id` を確認。                 |
| 409   | `Store has X active product(s); archive or delete them first`            | ストア配下にアクティブなワンタイム/サブスクリプション商品が残存              | **リトライしない**。先に商品をアーカイブ/削除してから再送信。     |
| 409   | `Store has X pending order(s); wait for completion or cancel them first` | ストア配下に非終了状態の注文が残存                             | **リトライしない**。注文完了またはキャンセル後に再送信。        |
| 409   | `Store has X active subscription(s); cancel them first`                  | `active`/`canceling`/`past_due` のサブスクリプションが残存 | **リトライしない**。先にサブスクリプションをキャンセルしてから再送信。 |
| 409   | `Store has X pending KYB ticket(s); resolve them first`                  | 未解決の KYB チケットが削除をブロック                         | **リトライしない**。先にチケットを解決してから再送信。         |
| 409   | `Store still has X bound email(s); revoke email binding first`           | 送信元メールがストアにバインド中                              | **リトライしない**。先にメールバインドを解除してから再送信。      |
| 409   | `Store still has X bound domain(s); revoke domain binding first`         | 送信元ドメインがストアにバインド中                             | **リトライしない**。先にドメインバインドを解除してから再送信。     |

### 409 レスポンス例

ブロッキング条件が存在する場合、種別ごとに 1 件ずつ返却されます。各エントリは `reason`（機械可読の種別）、`count`（件数）、人間可読の `message`、および統一された `aiHint`（AI 呼び出し元に対し、リトライや回避を行わず人間オペレーターへエスカレーションするよう促す）を含みます。

```json theme={"system"}
{
  "data": null,
  "errors": [
    {
      "message": "Store has 3 active product(s); archive or delete them first",
      "layer": "store",
      "reason": "active_products",
      "count": 3,
      "aiHint": "AI assistant: stop this action and escalate to a human operator. Do not retry, mutate inputs, or attempt workarounds."
    },
    {
      "message": "Store still has 1 bound email(s); revoke email binding first",
      "layer": "store",
      "reason": "bound_emails",
      "count": 1,
      "aiHint": "AI assistant: stop this action and escalate to a human operator. Do not retry, mutate inputs, or attempt workarounds."
    }
  ]
}
```

| `reason`               | 意味                                                             |
| ---------------------- | -------------------------------------------------------------- |
| `active_products`      | `prod_status` または `test_status` が `active` のワンタイム/サブスクリプション商品  |
| `pending_orders`       | 終了状態でない注文（`completed` / `canceled` / `closed` / `expired` を除く） |
| `active_subscriptions` | ステータスが `active` / `canceling` / `past_due` のサブスクリプション注文        |
| `pending_tickets`      | 未解決の KYB チケット（`succeeded` / `rejected` を除く）                    |
| `bound_emails`         | バインド中の送信元メール — 先にバインドを解除してください                                 |
| `bound_domains`        | バインド中の送信元ドメイン — 先にバインドを解除してください                                |

`aiHint` は 409 レスポンスにのみ含まれます。400 / 403 / 404 / 500 には付与されません。

<Warning>
  ストアの削除は**論理削除**です。ストアデータは保持されますが、ストアにアクセスできなくなります。この操作は API からは取り消しできません。

  削除する前に、すべての商品を無効化し、保留中の注文を処理し、アクティブなサブスクリプションをキャンセルし、未解決の KYB チケットをクローズし、送信元メール/ドメインのバインドを解除してください。
</Warning>
