資源
發佈事件
發佈自定義事件以觸發工作流和集成。
POST
/
api
/
v1
/
events
發佈事件
curl --request POST \
--url https://api.example.com/api/v1/events \
--header 'Content-Type: application/json' \
--data '
{
"orgId": "<string>",
"eventType": "<string>",
"payload": "<any>",
"sourceConnector": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/events"
payload = {
"orgId": "<string>",
"eventType": "<string>",
"payload": "<any>",
"sourceConnector": "<string>"
}
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({
orgId: '<string>',
eventType: '<string>',
payload: '<any>',
sourceConnector: '<string>'
})
};
fetch('https://api.example.com/api/v1/events', 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.example.com/api/v1/events",
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([
'orgId' => '<string>',
'eventType' => '<string>',
'payload' => '<any>',
'sourceConnector' => '<string>'
]),
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.example.com/api/v1/events"
payload := strings.NewReader("{\n \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\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.example.com/api/v1/events")
.header("Content-Type", "application/json")
.body("{\n \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/events")
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 \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body將自定義事件發佈到 Theo 事件總線。事件可以觸發工作流、連接器操作和技能激活。
身份驗證
需要 Bearer 令牌。參見身份驗證。請求正文
string
必填
該事件所屬組織的 UUID。
string
必填
事件類型標識符(例如
"claim.created"、"policy.renewed")。any
任意事件負載數據。
string
產生該事件的連接器 ID。
請求示例
curl -X POST https://www.hitheo.ai/api/v1/events \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"orgId": "org_abc123",
"eventType": "claim.created",
"payload": { "claimId": "CLM-001", "amount": 15000, "type": "auto" }
}'
響應
返回已發佈的事件對象,包含生成的id 和時間戳。
端點
POST /api/v1/events
需要通過 Bearer 令牌進行身份驗證。參見身份驗證。這個頁面有幫助嗎?
發佈事件
curl --request POST \
--url https://api.example.com/api/v1/events \
--header 'Content-Type: application/json' \
--data '
{
"orgId": "<string>",
"eventType": "<string>",
"payload": "<any>",
"sourceConnector": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/events"
payload = {
"orgId": "<string>",
"eventType": "<string>",
"payload": "<any>",
"sourceConnector": "<string>"
}
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({
orgId: '<string>',
eventType: '<string>',
payload: '<any>',
sourceConnector: '<string>'
})
};
fetch('https://api.example.com/api/v1/events', 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.example.com/api/v1/events",
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([
'orgId' => '<string>',
'eventType' => '<string>',
'payload' => '<any>',
'sourceConnector' => '<string>'
]),
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.example.com/api/v1/events"
payload := strings.NewReader("{\n \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\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.example.com/api/v1/events")
.header("Content-Type", "application/json")
.body("{\n \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/events")
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 \"orgId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"payload\": \"<any>\",\n \"sourceConnector\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body