> ## 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 | 是  | 要删除的 Store 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 响应示例

门店存在阻塞条件时按类型逐项返回。每项含 `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>
