管理
触发 Autopilot webhook
启动一次按照请求体中 prompt 执行的 Autopilot 运行。适用于从 CI/CD 流水线、发布脚本或内部工具中让 Autopilot 更新你的文档。
使用具有写入权限的组织 API 密钥进行身份验证。
POST
/
v2
/
autopilot
/
{projectId}
/
webhook
触发 Autopilot webhook
curl --request POST \
--url https://api.mintlify.com/v2/autopilot/{projectId}/webhook \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "We released v2.4 of the CLI. Add the new --watch flag to the CLI reference."
}
'import requests
url = "https://api.mintlify.com/v2/autopilot/{projectId}/webhook"
payload = { "prompt": "We released v2.4 of the CLI. Add the new --watch flag to the CLI reference." }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.'
})
};
fetch('https://api.mintlify.com/v2/autopilot/{projectId}/webhook', 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/v2/autopilot/{projectId}/webhook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mintlify.com/v2/autopilot/{projectId}/webhook"
payload := strings.NewReader("{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/v2/autopilot/{projectId}/webhook")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mintlify.com/v2/autopilot/{projectId}/webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"runId": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}使用此端点从你自己的工具启动一次 Autopilot 运行。每个请求都会将一次运行加入队列,该运行按照请求体中的
Autopilot 会像处理其他运行一样处理该 prompt。当它创建或更新拉取请求时,会像处理代码变更时一样分配审核者并通知你的团队。每次运行都会在 Autopilot 页面上显示为单独的会话线程。
如果 Autopilot 已暂停,该运行会等到你恢复 Autopilot 后再执行。
此端点与 触发部署、触发自动化 和 触发自动化 webhook 共享速率限制:每个组织每 10 秒最多 10 次请求。
当一次运行创建或更新拉取请求时,会消耗 250 积分。请参阅 Autopilot 积分。
prompt 执行,并使用与 Autopilot 其他运行相同的上下文、技能和审核设置。
必须为该项目启用 Autopilot。
- 发布脚本:在你创建标签或发布新版本 SDK 时,告诉 Autopilot 发布了什么。
- CI/CD 流水线:在部署或合并到
main之后,让 Autopilot 检查文档。 - 内部工具:从你已在使用的内部仪表盘、支持工具或定时任务发送文档请求。
Authorization: Bearer <api-key> 请求头模板的 Copy auth header 操作。
将 <api-key> 替换为一个未过期且具有写入权限的组织 API 密钥。在 API keys 页面创建或管理密钥。
通过 GitHub Action 让 Autopilot 为每次发布编写文档:
.github/workflows/autopilot-release.yml
on:
release:
types: [published]
jobs:
autopilot:
runs-on: ubuntu-latest
steps:
- run: |
curl -fsS -X POST \
"https://api.mintlify.com/v2/autopilot/$PROJECT_ID/webhook" \
-H "Authorization: Bearer ${{ secrets.MINTLIFY_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg tag "$TAG" '{prompt: "Release \($tag) was published. Update the changelog and any docs it affects."}')"
env:
PROJECT_ID: ${{ vars.MINTLIFY_PROJECT_ID }}
TAG: ${{ github.event.release.tag_name }}
⌘I
触发 Autopilot webhook
curl --request POST \
--url https://api.mintlify.com/v2/autopilot/{projectId}/webhook \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "We released v2.4 of the CLI. Add the new --watch flag to the CLI reference."
}
'import requests
url = "https://api.mintlify.com/v2/autopilot/{projectId}/webhook"
payload = { "prompt": "We released v2.4 of the CLI. Add the new --watch flag to the CLI reference." }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.'
})
};
fetch('https://api.mintlify.com/v2/autopilot/{projectId}/webhook', 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/v2/autopilot/{projectId}/webhook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mintlify.com/v2/autopilot/{projectId}/webhook"
payload := strings.NewReader("{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/v2/autopilot/{projectId}/webhook")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mintlify.com/v2/autopilot/{projectId}/webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"We released v2.4 of the CLI. Add the new --watch flag to the CLI reference.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"runId": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}{
"success": true,
"error": "<string>"
}