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

# 移除 Webhook

> 硬删除 Webhook（保留历史记录）

从门店中移除 Webhook。该操作为**硬删除** —— 记录会立即从 `store.store_webhooks` 中删除，无软删除标记。历史 `webhook_deliveries` 记录保留以供审计（`storeWebhookId` 外键被置为 `null`）。

```
POST /v1/actions/store/remove-webhook
```

**认证方式：** API Key（需要 owner 或 admin 角色）

## 请求体

| 字段   | 类型     | 必需 | 说明           |
| ---- | ------ | -- | ------------ |
| `id` | string | 是  | Webhook UUID |

## 请求示例

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

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

  const { webhook } = await client.webhooks.remove({
    id: "11111111-2222-3333-4444-555555555555",
  });
  // webhook 包含删除前的记录快照
  ```

  ```bash cURL theme={"system"}
  curl -X POST https://api.waffo.com/v1/actions/store/remove-webhook \
    -H "Content-Type: application/json" \
    -H "X-Merchant-Id: $WAFFO_MERCHANT_ID" \
    -H "X-Signature: ..." \
    -d '{ "id": "11111111-2222-3333-4444-555555555555" }'
  ```
</CodeGroup>

## 成功响应 (200)

返回删除前一刻的 Webhook 实体（便于调用方确认所删除的内容）。结构与 [`add-webhook`](/zh/api-reference/endpoints/webhooks/add-webhook#成功响应-200) 相同。

## 响应字段

| 字段          | 类型             | 说明                             |
| ----------- | -------------- | ------------------------------ |
| `id`        | string         | Webhook UUID                   |
| `storeId`   | string         | 所属门店的 UUID                     |
| `channel`   | string         | Webhook 通道                     |
| `url`       | string         | 目标 Webhook URL                 |
| `events`    | string\[]      | 订阅的事件类型                        |
| `testMode`  | boolean        | `true` 对测试交易触发，`false` 对生产交易触发 |
| `secret`    | string \| null | 通道特定凭据，未设置时为 `null`            |
| `createdAt` | string         | 创建时间戳（ISO 8601）                |
| `updatedAt` | string         | 最后更新时间戳（ISO 8601）              |

## 错误响应

> **重试策略**：4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试（起步 5s，最多 3 次）。

| 状态码 | `errors[0].message`                                | 含义                                         | 推荐处理                         |
| --- | -------------------------------------------------- | ------------------------------------------ | ---------------------------- |
| 400 | `Missing required field: id`                       | 未提供 `id`                                   | 修正请求体后重发                     |
| 400 | `id must be a valid UUID`                          | `id` 不是合法 UUID                             | 修正 `id` 后重发                  |
| 403 | `Not authorized to manage webhooks for this store` | 调用方在所属门店上的 merchant 角色不是 `owner` 或 `admin` | 换用拥有所需角色的 API Key            |
| 404 | `Webhook not found`                                | 指定 `id` 的 webhook 不存在（或已被删除）               | Webhook 已不存在 — 按成功处理，并对齐本地状态 |
| 500 | `Internal server error`                            | 服务端意外失败                                    | 指数退避重试（起步 5s，最多 3 次）         |
