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

<!-- agent-signals: reading_time_min: 1 · est_tokens: 862 · updated: 2026-07-30 -->
Related: [触发预览部署](/zh/api/preview/trigger.md), [检测 AI 风格的文本](/zh/api/admin/deslop.md)

使用此端点可按需触发计划自动化，而无需等待其下一次预定运行。该自动化的行为与常规计划运行完全相同：会处理自上次完成运行以来发生的所有变更。

此端点仅支持配置为 **Custom schedule** 触发器的自动化。对于使用其他触发器（如 **Code change** 或 **Content update**）的自动化，请求会返回 `400` 错误。

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

* **CI/CD 流水线**：在每次合并到 `main` 时运行 **Update from code changes** 自动化，使文档按发布节奏更新，而不是按固定计划。
* **发布事件**：在你打出发布标签时运行 **Draft changelog** 自动化，使变更日志与发布同时起草。
* **自定义工具**：从内部工具、Slack 命令或已有的计划任务中触发自动化。

<div id="find-the-automation-id">
  ## 查找自动化 ID [#查找自动化-id]
</div>

在控制台的 [Automations](https://app.mintlify.com/products/automations) 页面，从自动化的设置面板中复制自动化 ID。

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

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

```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/v1/workflow/$PROJECT_ID/$WORKFLOW_ID/trigger" \
            -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>

此端点与 [Trigger update](/zh/api/update/trigger) 共享速率限制：每个组织每 10 秒最多 10 个请求。触发的运行与计划运行按相同速率消耗积分。

`POST /workflow/{projectId}/{workflowSchemaId}/trigger`

立即触发计划自动化运行，而无需等待其下一次预定时间。适合从 CI/CD 流水线中运行自动化，例如在每次合并到默认分支时运行的 GitHub Action。仅支持触发计划（自定义计划）自动化。该次运行会处理自上次完成运行以来的变更，与常规计划运行完全相同。

使用管理员 API 密钥进行身份验证。

## OpenAPI

```json
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "name": "projectId",
      "in": "path",
      "description": "你的项目 ID。可在控制台的 [API keys](https://app.mintlify.com/settings/organization/api-keys) 页面中复制。",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "workflowSchemaId",
      "in": "path",
      "description": "要触发的自动化的 ID。可在控制台的 [Automations](https://app.mintlify.com/products/automations) 页面，从自动化的设置面板中复制。",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "202": {
      "description": "自动化运行已成功加入队列。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "schemaId": {
                "type": "string",
                "description": "被触发的自动化的 ID。"
              },
              "instanceId": {
                "type": "string",
                "description": "已入队自动化运行的 ID。会出现在 [Automation Runs](https://app.mintlify.com/products/automations) 页面的运行历史中。"
              },
              "jobId": {
                "type": "string",
                "description": "处理此次运行的后台任务 ID。"
              }
            }
          }
        }
      }
    },
    "400": {
      "description": "无效请求。自动化 ID 格式错误、自动化未激活，或该自动化未配置为使用自定义计划。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "404": {
      "description": "未找到该自动化，或该自动化不属于此项目。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
```
