预览模板
curl --request POST \
--url 'https://api.flashcat.cloud/template/preview?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"content": "**{{.Title}}** is {{.IncidentSeverity}}",
"type": "feishu_app",
"incident_id": "664a1b2c3d4e5f6a7b8c9d0e",
"incident_card_hidden_fields": {
"feishu_app": [
"responders"
]
}
}
'import requests
url = "https://api.flashcat.cloud/template/preview?app_key="
payload = {
"content": "**{{.Title}}** is {{.IncidentSeverity}}",
"type": "feishu_app",
"incident_id": "664a1b2c3d4e5f6a7b8c9d0e",
"incident_card_hidden_fields": { "feishu_app": ["responders"] }
}
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({
content: '**{{.Title}}** is {{.IncidentSeverity}}',
type: 'feishu_app',
incident_id: '664a1b2c3d4e5f6a7b8c9d0e',
incident_card_hidden_fields: {feishu_app: ['responders']}
})
};
fetch('https://api.flashcat.cloud/template/preview?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/template/preview?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([
'content' => '**{{.Title}}** is {{.IncidentSeverity}}',
'type' => 'feishu_app',
'incident_id' => '664a1b2c3d4e5f6a7b8c9d0e',
'incident_card_hidden_fields' => [
'feishu_app' => [
'responders'
]
]
]),
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/template/preview?app_key="
payload := strings.NewReader("{\n \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\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/template/preview?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/template/preview?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 \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"success": true,
"content": "**Database latency spike** is Critical",
"message": "",
"card": {
"title": "Database latency spike",
"elements": [
{
"type": "template"
},
{
"type": "divider"
},
{
"type": "actions",
"actions": [
{
"text": "Acknowledge",
"style": "primary"
},
{
"text": "Resolve",
"style": "danger"
},
{
"text": "Snooze",
"style": "select"
}
]
}
]
},
"blocks": [
{
"type": "markdown",
"content": "**Database latency spike** is Critical"
}
],
"size_bytes": 38,
"size_limit_bytes": 30720
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter 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
/
template
/
preview
预览模板
curl --request POST \
--url 'https://api.flashcat.cloud/template/preview?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"content": "**{{.Title}}** is {{.IncidentSeverity}}",
"type": "feishu_app",
"incident_id": "664a1b2c3d4e5f6a7b8c9d0e",
"incident_card_hidden_fields": {
"feishu_app": [
"responders"
]
}
}
'import requests
url = "https://api.flashcat.cloud/template/preview?app_key="
payload = {
"content": "**{{.Title}}** is {{.IncidentSeverity}}",
"type": "feishu_app",
"incident_id": "664a1b2c3d4e5f6a7b8c9d0e",
"incident_card_hidden_fields": { "feishu_app": ["responders"] }
}
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({
content: '**{{.Title}}** is {{.IncidentSeverity}}',
type: 'feishu_app',
incident_id: '664a1b2c3d4e5f6a7b8c9d0e',
incident_card_hidden_fields: {feishu_app: ['responders']}
})
};
fetch('https://api.flashcat.cloud/template/preview?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/template/preview?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([
'content' => '**{{.Title}}** is {{.IncidentSeverity}}',
'type' => 'feishu_app',
'incident_id' => '664a1b2c3d4e5f6a7b8c9d0e',
'incident_card_hidden_fields' => [
'feishu_app' => [
'responders'
]
]
]),
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/template/preview?app_key="
payload := strings.NewReader("{\n \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\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/template/preview?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/template/preview?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 \"content\": \"**{{.Title}}** is {{.IncidentSeverity}}\",\n \"type\": \"feishu_app\",\n \"incident_id\": \"664a1b2c3d4e5f6a7b8c9d0e\",\n \"incident_card_hidden_fields\": {\n \"feishu_app\": [\n \"responders\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"success": true,
"content": "**Database latency spike** is Critical",
"message": "",
"card": {
"title": "Database latency spike",
"elements": [
{
"type": "template"
},
{
"type": "divider"
},
{
"type": "actions",
"actions": [
{
"text": "Acknowledge",
"style": "primary"
},
{
"text": "Resolve",
"style": "danger"
},
{
"text": "Snooze",
"style": "select"
}
]
}
]
},
"blocks": [
{
"type": "markdown",
"content": "**Database latency spike** is Critical"
}
],
"size_bytes": 38,
"size_limit_bytes": 30720
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter 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 次/秒 |
| 权限要求 | 模板查看(on-call) 或 模板管理(on-call) |
使用说明
- 传
incident_id时用该故障渲染(须为账户内存在的故障,否则返回InvalidParameter),否则用模拟故障。content为空时预览该通道的内置预设内容。 - 模板错误不会返回 HTTP 错误:响应中
success为false,message说明原因。 card描述渲染结果外层的消息框架(邮件主题、IM 应用卡片的元素和按钮),仅email、feishu_app、dingtalk_app、wecom_app、slack_app、teams_app返回,其他类型省略。依赖集成的按钮(AI 分析、作战室)不会出现。incident_card_hidden_fields作用于 IM 应用卡片;不支持的应用类型或字段名返回InvalidParameter。- 该接口不会发送消息,也不会保存任何内容。
授权
请求体
application/json
模板预览请求。
要预览的通道,其他取值返回 InvalidParameter。
email:邮件正文(HTML 模板)。sms、voice:短信文本和语音电话话术。push:移动 App 推送(内容固定,忽略content)。dingtalk、wecom、feishu、zoom、telegram、slack:机器人(Webhook)消息。feishu_app、dingtalk_app、wecom_app、slack_app、teams_app:IM 应用卡片。
可用选项:
email, sms, voice, push, dingtalk, wecom, feishu, zoom, telegram, slack, feishu_app, dingtalk_app, wecom_app, slack_app, teams_app 此页面对您有帮助吗?