管理
触发自动化
立即触发计划自动化运行,而无需等待其下一次预定时间。适合从 CI/CD 流水线中运行自动化,例如在每次合并到默认分支时运行的 GitHub Action。仅支持触发计划(自定义计划)自动化。该次运行会处理自上次完成运行以来的变更,与常规计划运行完全相同。
POST
/
workflow
/
{projectId}
/
{workflowSchemaId}
/
trigger
触发自动化
curl --request POST \
--url https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"schemaId": "<string>",
"instanceId": "<string>",
"jobId": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}使用此端点可按需触发计划自动化,而无需等待其下一次预定运行。该自动化的行为与常规计划运行完全相同:会处理自上次完成运行以来发生的所有变更。
此端点仅支持配置为 Custom schedule 触发器的自动化。对于使用其他触发器(如 Code change 或 Content update)的自动化,请求会返回
在控制台的 Automations 页面,从自动化的设置面板中复制自动化 ID。
每当代码合并到
此端点与 Trigger update 共享速率限制:每个组织每 10 秒最多 10 个请求。触发的运行与计划运行按相同速率消耗积分。
400 错误。
用例
- CI/CD 流水线:在每次合并到
main时运行 Update from code changes 自动化,使文档按发布节奏更新,而不是按固定计划。 - 发布事件:在你打出发布标签时运行 Draft changelog 自动化,使变更日志与发布同时起草。
- 自定义工具:从内部工具、Slack 命令或已有的计划任务中触发自动化。
查找自动化 ID
示例
main 时,从 GitHub Action 触发自动化:
.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 }}
速率限制
授权
Authorization 请求头需要使用 Bearer token。请使用以 mint_ 为前缀的管理员 API key。该 key 是仅供服务端使用的机密密钥。你可以在控制台的 API keys 页面 中生成一个。
路径参数
要触发的自动化的 ID。可在控制台的 Automations 页面,从自动化的设置面板中复制。
响应
自动化运行已成功加入队列。
此页面对您有帮助吗?
⌘I
触发自动化
curl --request POST \
--url https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mintlify.com/v1/workflow/{projectId}/{workflowSchemaId}/trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"schemaId": "<string>",
"instanceId": "<string>",
"jobId": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}