运行自动化规则
curl --request POST \
--url 'https://api.flashcat.cloud/safari/automation/rule/run?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b"
}
'import requests
url = "https://api.flashcat.cloud/safari/automation/rule/run?app_key="
payload = { "rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({rule_id: 'arule_7NnLzY2Qp8xS4kUaV3mR6b'})
};
fetch('https://api.flashcat.cloud/safari/automation/rule/run?app_key=', 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.flashcat.cloud/safari/automation/rule/run?app_key=",
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([
'rule_id' => 'arule_7NnLzY2Qp8xS4kUaV3mR6b'
]),
CURLOPT_HTTPHEADER => [
"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.flashcat.cloud/safari/automation/rule/run?app_key="
payload := strings.NewReader("{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.flashcat.cloud/safari/automation/rule/run?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/safari/automation/rule/run?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b",
"trigger_kind": "manual",
"preflight": {
"ok": true,
"checks": [
"rule_loaded",
"actor_authorized",
"app_allowed",
"runtime_scope_resolved",
"rule_config_valid"
],
"scope": "team",
"owner_id": 80011,
"team_id": 123,
"app_name": "ai-sre"
},
"run": {
"run_id": "trun_5oDvqiG64uur6sBNsTc4u",
"session_id": "sess_f8oDvqiG64uur6sBNsTc4u"
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter skill_id is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "AccessDenied",
"message": "Access Denied."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}自动化
运行自动化规则
立即运行一次自动化规则,不受其触发器和启用状态限制。
POST
/
safari
/
automation
/
rule
/
run
运行自动化规则
curl --request POST \
--url 'https://api.flashcat.cloud/safari/automation/rule/run?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b"
}
'import requests
url = "https://api.flashcat.cloud/safari/automation/rule/run?app_key="
payload = { "rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({rule_id: 'arule_7NnLzY2Qp8xS4kUaV3mR6b'})
};
fetch('https://api.flashcat.cloud/safari/automation/rule/run?app_key=', 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.flashcat.cloud/safari/automation/rule/run?app_key=",
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([
'rule_id' => 'arule_7NnLzY2Qp8xS4kUaV3mR6b'
]),
CURLOPT_HTTPHEADER => [
"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.flashcat.cloud/safari/automation/rule/run?app_key="
payload := strings.NewReader("{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.flashcat.cloud/safari/automation/rule/run?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/safari/automation/rule/run?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"rule_id\": \"arule_7NnLzY2Qp8xS4kUaV3mR6b\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"rule_id": "arule_7NnLzY2Qp8xS4kUaV3mR6b",
"trigger_kind": "manual",
"preflight": {
"ok": true,
"checks": [
"rule_loaded",
"actor_authorized",
"app_allowed",
"runtime_scope_resolved",
"rule_config_valid"
],
"scope": "team",
"owner_id": 80011,
"team_id": 123,
"app_name": "ai-sre"
},
"run": {
"run_id": "trun_5oDvqiG64uur6sBNsTc4u",
"session_id": "sess_f8oDvqiG64uur6sBNsTc4u"
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter skill_id is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "AccessDenied",
"message": "Access Denied."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}限制说明
| 项目 | 说明 |
|---|---|
| 速率限制 | 每个账户 100 次/分钟;5 次/秒 |
| 权限要求 | Automation 管理(ai-sre) |
使用说明
- 手动运行不要求规则处于启用状态。规则配置无效(例如使用了规则作用域不允许的 BYOC 运行器),或唯一启用的触发器是作战室触发器(这类规则没有 Web 控制台运行)时,会在创建运行前返回
400。 - 创建者已离开账户的个人规则会被自动停用,本调用返回
400。 - 同一规则每分钟最多手动运行一次;窗口内的第二次调用返回
429,code为"RequestTooFrequently"。 - 管理权限:个人规则(
team_id=0)仅创建者可管理;团队规则仅该团队成员可管理。账户所有者和管理员没有例外,需加入该团队。 - 同一规则正在执行另一次更新、删除或手动运行时,本调用返回 HTTP
423,code为"RequestLocked",请稍后重试。 - 调用在 Agent 会话启动后即返回,不等待运行结束。可用列出自动化运行记录(
trigger_kind=manual)查询完成情况。 - 对在 IM 群聊中运行的规则(
execution_place=im),响应不包含run.session_id。 - 每次调用都会记录到账户审计日志。
授权
在 Flashduty 控制台 我的 → APP Key 中创建的 APP Key。可通过 query 参数 app_key 或请求头 Fd-App-Key 传入。实际可访问范围是该 APP Key 的权限范围与创建者当前角色权限的交集,请妥善保管。
请求体
application/json
规则 ID,取自 POST /safari/automation/rule/list 返回的列表。
响应
成功
所有 Flashduty 公开 API 共用的标准响应结构。成功时 data 为接口专属载荷且不含 error;失败时 error 存在而 data 缺失。request_id 始终存在,并会同步写入 Flashcat-Request-Id 响应头。
此页面对您有帮助吗?