# 触发自动化 webhook (/zh/api/automations/webhook)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1583 · updated: 2026-09-23 -->
Related: [触发自动化](/zh/api/automations/trigger.md), [创建 assistant 消息](/zh/api/assistant/create-assistant-message-v2.md)

使用此端点运行一个配置为 **Webhook** 触发器的自定义自动化。每次请求会将一次运行加入队列，该运行使用自动化保存的 prompt 并读取仓库的完整历史记录。请求体会被忽略。

此端点仅支持配置了 webhook 触发器的[自定义自动化](/zh/automations/create)。预定义自动化以及使用其他任何触发器的自动化都会返回 `404` 响应。若要按需触发一个计划型自定义自动化，请改用[触发自动化](/zh/api/automations/trigger)。

<div id="use-cases">
  ## 用例 [#用例]
</div>

* **CI/CD 流水线**：在每次合并到 `main` 或发布之后运行自定义自动化，无需等待计划运行。
* **发布事件**：在打出标签或发布新 SDK 版本时，从发布脚本运行自定义自动化。
* **内部工具**：从内部仪表板、Slack 命令或已有的计划任务中触发自动化。

<div id="get-the-webhook-url-and-auth-header">
  ## 获取 webhook URL 和身份验证请求头 [#获取-webhook-url-和身份验证请求头]
</div>

在控制台中打开[自动化](https://app.mintlify.com/products/automations)页面，点击具有 webhook 触发器的自定义自动化上的 <Icon icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z&#x22; stroke=&#x22;currentColor&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" /> 设置按钮。触发器卡片会显示完整的 webhook URL，以及用于 `Authorization: Bearer <api-key>` 请求头模板的 **Copy auth header** 操作。

将 `<api-key>` 替换为具有写入权限且未过期的组织 API 密钥。在 [API keys](https://app.mintlify.com/settings/organization/api-keys) 页面创建或管理密钥。自动化不会为你创建、存储或轮换密钥。

<div id="example">
  ## 示例 [#示例]
</div>

每当代码合并到 `main` 时，从 GitHub Action 触发一个 webhook 自动化：

```yaml title=".github/workflows/trigger-docs.yml"
on:
  push:
    branches: [main]

jobs:
  trigger:
    runs-on: ubuntu-latest
    steps:
      - run: |
          curl -fsS -X POST \
            "https://api.mintlify.com/v2/workflow/$PROJECT_ID/$WORKFLOW_ID/webhook" \
            -H "Authorization: Bearer ${{ secrets.MINTLIFY_API_KEY }}"
        env:
          PROJECT_ID: ${{ vars.MINTLIFY_PROJECT_ID }}
          WORKFLOW_ID: ${{ vars.MINTLIFY_WORKFLOW_ID }}
```

<div id="rate-limits">
  ## 速率限制 [#速率限制]
</div>

此端点与[触发更新](/zh/api/update/trigger)和[触发自动化](/zh/api/automations/trigger)共享速率限制：每个组织每 10 秒最多 10 次请求。每次入队运行消耗的额度与其他任何自定义自动化运行相同。请参见[额度定价](/zh/credits)。

`POST /v2/workflow/{projectId}/{workflowSchemaId}/webhook`

为一个具有 webhook 触发器的自定义自动化排队一次运行，而不必等待该触发器配置的事件。适用于从 CI/CD 流水线、发布脚本或任何其他已经发送事件的系统运行自动化。只能触发配置了 webhook 触发器的自定义自动化；使用其他触发器的自动化会返回 `404` 响应。

请使用具有写入访问权限的组织 API 密钥进行身份验证。

## OpenAPI

```json
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "name": "projectId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      },
      "description": "你的项目 ID。可以从控制台的 [API keys](https://app.mintlify.com/settings/organization/api-keys) 页面复制。"
    },
    {
      "name": "workflowSchemaId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      },
      "description": "要触发的自动化的 ID。可以从控制台[自动化](https://app.mintlify.com/products/automations)页面上该自动化的设置面板复制。"
    }
  ],
  "responses": {
    "202": {
      "description": "自动化运行已成功加入队列。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean"
              },
              "runId": {
                "type": "string",
                "description": "已排队的自动化运行的 ID。会出现在[自动化](https://app.mintlify.com/products/automations)页面的运行历史中。"
              }
            }
          }
        }
      }
    },
    "400": {
      "description": "自动化 ID 格式无效。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          }
        }
      }
    },
    "402": {
      "description": "本计费周期的 AI 额度已耗尽。请升级你的套餐或等待额度续期。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          }
        }
      }
    },
    "404": {
      "description": "未找到该自动化，或该自动化未处于活动状态、不属于此项目，或未配置 webhook 触发器。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          }
        }
      }
    },
    "503": {
      "description": "额度检查失败。请重试该请求。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          }
        }
      }
    }
  }
}
```
