> ## Documentation Index
> Fetch the complete documentation index at: https://adminroletesting-mintlify-999c9ea9.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 触发自动化

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

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

此端点仅支持配置为 **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
</div>

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

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

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

```yaml .github/workflows/trigger-docs.yml theme={null}
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) 共享速率限制：每个组织每分钟最多 5 个请求。触发的运行与计划运行按相同速率消耗积分。


## OpenAPI

````yaml zh/openapi.json POST /workflow/{projectId}/{workflowSchemaId}/trigger
openapi: 3.0.1
info:
  title: Mintlify External API
  description: 用于管理 Mintlify 文档并访问各类资源的 API。
  version: 1.0.0
servers:
  - url: https://api.mintlify.com/v1
security:
  - bearerAuth: []
paths:
  /workflow/{projectId}/{workflowSchemaId}/trigger:
    post:
      summary: 触发自动化
      description: >-
        立即触发计划自动化运行，而无需等待其下一次预定时间。适合从 CI/CD 流水线中运行自动化，例如在每次合并到默认分支时运行的 GitHub
        Action。仅支持触发计划（自定义计划）自动化。该次运行会处理自上次完成运行以来的变更，与常规计划运行完全相同。
      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
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authorization 请求头需要使用 Bearer token。请使用以 `mint_` 为前缀的管理员 API key。该 key
        是仅供服务端使用的机密密钥。你可以在控制台的 [API keys
        页面](https://dashboard.mintlify.com/settings/organization/api-keys)
        中生成一个。

````