RoomScope

最後更新

提醒

在 LIVE 事件發生時觸發的提醒規則(Webhook、電子郵件、應用程式內、Telegram)。

所有操作都以 API 金鑰進行身分驗證 (Authorization: Bearer <key>) ;錯誤一律使用共通的錯誤格式,說明請見 錯誤. 本頁由 API 的 OpenAPI 文件產生。

列出提醒規則

GET/v1/alerts/rules

工作區的所有規則及其通道。簽章密鑰絕不會再次回傳。

權限範圍webhook:manage點數免費

請求

curl "https://api.toktokdata.live/v1/alerts/rules" \  -H "Authorization: Bearer $ROOMSCOPE_API_KEY"

回應

200 OK
{  "rules": [    {      "id": "7d01133d-6ecb-5101-a9c0-e23e4755bad9",      "name": "Envelopes from Linh",      "creatorUniqueId": "linh.live",      "region": null,      "eventTypes": [        "envelope"      ],      "minScore": null,      "minRate": null,      "minDiamondCount": 100,      "goodyBagAllowAllViewers": null,      "goodyBagMaxRequiredLevel": null,      "enabled": true,      "createdAt": "2026-11-01T10:51:45.582Z",      "updatedAt": "2026-11-01T10:51:45.582Z",      "channels": [        {          "id": "3d0d4dc5-6993-55ab-a1cd-ffbe7db95507",          "channelType": "in_app",          "target": null,          "enabled": true,          "hasSigningSecret": false        }      ]    }  ],  "provenance": {    "observedAt": "2026-11-01T10:00:00.000Z",    "freshness": "near_realtime",    "source": "workspace_alert_rules",    "sourceKind": "derived",    "coverageStatus": "observed",    "methodologyVersion": "alert-rules-v1",    "window": null  }}

錯誤

  • 400 參數或請求主體無效;code 會指出問題所在。
  • 401 API 金鑰缺少或不存在。
  • 403 金鑰缺少該權限範圍,或方案未包含此功能。
  • 429 超過請求速率;請遵守 Retry-After。

建立提醒規則

POST/v1/alerts/rules

規則會針對特定事件類型觀察一位創作者(或整個地區),並推送到其通道。Webhook 通道的簽章密鑰只會在 webhookSecrets 中回傳一次。

權限範圍webhook:manage點數免費

請求主體

請求主體 · POST /v1/alerts/rules
NameTypeDescription
nameRequired
string顯示於通知中。
creatorUniqueIdOptional
string | null觀察單一創作者;省略則代表整個地區。
regionOptional
string | null
eventTypesOptional
("gift" | "envelope" | "goodyBag" | "*")[]
minDiamondCountOptional
integer | null忽略鑽石值低於此數的事件。
enabledOptional
boolean
Default: true
channelsOptional
object[]

請求

curl -X POST "https://api.toktokdata.live/v1/alerts/rules" \  -H "Authorization: Bearer $ROOMSCOPE_API_KEY" \  -H "Content-Type: application/json" \  -d '{"name":"Envelopes from Linh","creatorUniqueId":"linh.live","eventTypes":["envelope"],"minDiamondCount":100,"channels":[{"channelType":"webhook","target":"https://example.com/hooks/roomscope"}]}'

回應

201 Created
{  "rule": {    "id": "7d01133d-6ecb-5101-a9c0-e23e4755bad9",    "name": "Envelopes from Linh",    "creatorUniqueId": "linh.live",    "region": null,    "eventTypes": [      "envelope"    ],    "minScore": null,    "minRate": null,    "minDiamondCount": 100,    "goodyBagAllowAllViewers": null,    "goodyBagMaxRequiredLevel": null,    "enabled": true,    "createdAt": "2026-11-01T10:51:45.582Z",    "updatedAt": "2026-11-01T10:51:45.582Z",    "channels": [      {        "id": "3d0d4dc5-6993-55ab-a1cd-ffbe7db95507",        "channelType": "in_app",        "target": null,        "enabled": true,        "hasSigningSecret": false      }    ]  },  "webhookSecrets": []}

錯誤

  • 400 參數或請求主體無效;code 會指出問題所在。
  • 401 API 金鑰缺少或不存在。
  • 403 金鑰缺少該權限範圍,或方案未包含此功能。
  • 429 超過請求速率;請遵守 Retry-After。

更新提醒規則

PATCH/v1/alerts/rules/{rule_id}

只需傳送要變更的欄位;channels 會取代整個清單。

權限範圍webhook:manage點數免費

路徑參數

路徑參數 · PATCH /v1/alerts/rules/{rule_id}
NameTypeDescription
rule_idRequired
string提醒規則 ID(UUID)。

請求主體

請求主體 · PATCH /v1/alerts/rules/{rule_id}
NameTypeDescription
nameOptional
string顯示於通知中。
creatorUniqueIdOptional
string | null觀察單一創作者;省略則代表整個地區。
regionOptional
string | null
eventTypesOptional
("gift" | "envelope" | "goodyBag" | "*")[]
minDiamondCountOptional
integer | null忽略鑽石值低於此數的事件。
enabledOptional
boolean
Default: true
channelsOptional
object[]

請求

curl -X PATCH "https://api.toktokdata.live/v1/alerts/rules/7d01133d-6ecb-5101-a9c0-e23e4755bad9" \  -H "Authorization: Bearer $ROOMSCOPE_API_KEY" \  -H "Content-Type: application/json" \  -d '{"enabled":false}'

回應

200 OK
{  "id": "7d01133d-6ecb-5101-a9c0-e23e4755bad9",  "name": "Envelopes from Linh",  "creatorUniqueId": "linh.live",  "region": null,  "eventTypes": [    "envelope"  ],  "minScore": null,  "minRate": null,  "minDiamondCount": 100,  "goodyBagAllowAllViewers": null,  "goodyBagMaxRequiredLevel": null,  "enabled": true,  "createdAt": "2026-11-01T10:51:45.582Z",  "updatedAt": "2026-11-01T10:51:45.582Z",  "channels": [    {      "id": "3d0d4dc5-6993-55ab-a1cd-ffbe7db95507",      "channelType": "in_app",      "target": null,      "enabled": true,      "hasSigningSecret": false    }  ]}

錯誤

  • 400 參數或請求主體無效;code 會指出問題所在。
  • 401 API 金鑰缺少或不存在。
  • 403 金鑰缺少該權限範圍,或方案未包含此功能。
  • 429 超過請求速率;請遵守 Retry-After。

刪除提醒規則

DELETE/v1/alerts/rules/{rule_id}

刪除規則及其通道。不回傳任何主體。

權限範圍webhook:manage點數免費

路徑參數

路徑參數 · DELETE /v1/alerts/rules/{rule_id}
NameTypeDescription
rule_idRequired
string提醒規則 ID(UUID)。

請求

curl -X DELETE "https://api.toktokdata.live/v1/alerts/rules/7d01133d-6ecb-5101-a9c0-e23e4755bad9" \  -H "Authorization: Bearer $ROOMSCOPE_API_KEY"

回應

204 回應,不含主體。

錯誤

  • 400 參數或請求主體無效;code 會指出問題所在。
  • 401 API 金鑰缺少或不存在。
  • 403 金鑰缺少該權限範圍,或方案未包含此功能。
  • 429 超過請求速率;請遵守 Retry-After。

傳送測試通知

POST/v1/alerts/rules/{rule_id}/test

將一個模擬事件推送到該規則所有已啟用的通道。

權限範圍webhook:manage點數免費

路徑參數

路徑參數 · POST /v1/alerts/rules/{rule_id}/test
NameTypeDescription
rule_idRequired
string提醒規則 ID(UUID)。

請求

curl -X POST "https://api.toktokdata.live/v1/alerts/rules/7d01133d-6ecb-5101-a9c0-e23e4755bad9/test" \  -H "Authorization: Bearer $ROOMSCOPE_API_KEY"

回應

200 OK
{  "enqueued": 1}

錯誤

  • 400 參數或請求主體無效;code 會指出問題所在。
  • 401 API 金鑰缺少或不存在。
  • 403 金鑰缺少該權限範圍,或方案未包含此功能。
  • 429 超過請求速率;請遵守 Retry-After。
這個頁面對你有幫助嗎?