SaaS
Documentation

Getting Started

  • Introduction
  • Quick Start

Core Features

  • Device Management
  • Scene Configuration
  • AI Analysis
  • LLM / VLM
  • Alert System

API Reference

  • API Overview
  • API Keys
  • Devices
  • Scenes
  • Alerts
  • Analysis Control
  • Data Query
  • LLM / VLM API
  • Billing Dashboard
  • Usage API
  • Admin Quota
  • Webhook
  • SSE Streaming

References

  • Metric Paths
  • Error Codes
  • Changelog

Webhook API

Webhook 用於接收系統事件通知,包含告警觸發、設備上下線等即時事件。

💡 每個用戶只能設定一個 Webhook 端點。

端點概覽

方法路徑說明
GET/api/v1/users/me/webhook取得 Webhook 設定
POST/api/v1/users/me/webhook建立 Webhook 設定
PATCH/api/v1/users/me/webhook更新 Webhook 設定
DELETE/api/v1/users/me/webhook刪除 Webhook 設定
POST/api/v1/users/me/webhook/test測試 Webhook
GET/api/v1/users/me/webhook/secret取得 Webhook 密鑰
POST/api/v1/users/me/webhook/secret/regenerate重新產生密鑰
GET/api/v1/users/me/webhook/deliveries查詢投遞紀錄

使用場景

  • 即時通知:告警觸發時即時推送到您的伺服器
  • 系統整合:與 Slack、Teams、PagerDuty 等整合
  • 自動化:觸發自動化工作流程

建立 Webhook 設定

POST /api/v1/users/me/webhook

請求參數

參數型別必填範圍/限制說明
urlString✅HTTPS URL,最大 500 字元Webhook URL
nameString❌最大 100 字元顯示名稱
secretString❌16-128 字元簽名密鑰(不填則自動產生)
subscribedTypesString[]❌見下方訂閱事件類型(不填則訂閱全部)
timeoutMsNumber❌1000-30000請求超時(毫秒),預設 5000
maxRetriesNumber❌0-5失敗重試次數,預設 3

事件類型 (subscribedTypes)

值說明
analysis_started分析開始
analysis_stopped分析停止
analysis_error分析錯誤
alert_triggered告警觸發
device_offline設備離線
device_online設備上線
device_analysis_error設備分析錯誤
node_offline計算節點離線
node_online計算節點上線
node_error計算節點錯誤
quota_warning配額警告 (80%)
quota_exceeded配額超限 (100%)
billing_cycle_completed帳單週期完成
maintenance_scheduled計劃性維護通知
system_announcement系統公告

請求範例

{
  "url": "https://your-server.com/webhook/saas",
  "name": "主要通知 Webhook",
  "subscribedTypes": [
    "alert_triggered",
    "device_offline",
    "analysis_error"
  ],
  "timeoutMs": 5000,
  "maxRetries": 3
}

Webhook 請求格式

當事件發生時,系統會發送 POST 請求:

HTTP 標頭

標頭說明
Content-Typeapplication/json
X-SaaS-Signaturesha256=... HMAC-SHA256 簽名
X-SaaS-TimestampUnix 時間戳
X-SaaS-Event事件類型
X-SaaS-Delivery-Id投遞 ID

Payload 結構(告警觸發範例)

{
  "id": "event-uuid",
  "type": "alert_triggered",
  "timestamp": "2026-01-29T10:30:00Z",
  "data": {
    "ruleId": "rule-uuid",
    "ruleName": "排隊人數過多警報",
    "sceneId": "scene-uuid",
    "sceneName": "櫃台排隊監控",
    "deviceId": "device-uuid",
    "severity": "warning",
    "metricPath": "current.inQueue",
    "operator": "GT",
    "threshold": 10,
    "actualValue": 15,
    "message": "排隊人數 (15) 超過閾值 (10)",
    "snapshotUrls": ["https://storage.example.com/snapshot.jpg"]
  }
}

簽名驗證

使用 secret 驗證請求來源:

const crypto = require('crypto');

function verifyWebhook(payload, signature, timestamp, secret) {
  const message = `${timestamp}.${JSON.stringify(payload)}`;
  const expected = crypto
    .createHmac('sha256', secret)
    .update(message)
    .digest('hex');
  
  return signature === `sha256=${expected}`;
}

查詢投遞紀錄

GET /api/v1/users/me/webhook/deliveries

查詢參數

參數型別必填說明
pageNumber❌頁碼(預設 1)
limitNumber❌每頁筆數(預設 20,最大 100)
statusString (enum)❌success / failed / pending
deviceIdUUID❌篩選特定設備
sceneIdUUID❌篩選特定場景
startDateISO 8601❌起始時間
endDateISO 8601❌結束時間

響應範例

{
  "data": [
    {
      "id": "delivery-uuid",
      "webhookUrl": "https://your-server.com/webhook/luminys",
      "notificationId": "notif-uuid",
      "alertEventId": "alert-event-uuid",
      "notificationType": "alert_triggered",
      "severity": "warning",
      "deviceId": "device-uuid",
      "sceneId": "scene-uuid",
      "payload": { "...完整通知內容": true },
      "status": "success",
      "httpStatusCode": 200,
      "responseTimeMs": 152,
      "responseBody": "{\"ok\":true}",
      "errorMessage": null,
      "attemptNumber": 1,
      "maxAttempts": 3,
      "isFinalAttempt": true,
      "createdAt": "2026-01-29T10:30:05Z"
    }
  ],
  "pagination": {
    "limit": 20,
    "currentPage": 1,
    "totalRecords": 42,
    "totalPages": 3,
    "nextPage": 2,
    "previousPage": null
  }
}

💡 投遞紀錄保留 30 天,超過自動清除。

SaaS

AI-powered intelligent video analytics platform, empowering your surveillance system.

Product

  • Features
  • Pricing
  • Changelog

Resources

  • Documentation
  • API Reference
  • Examples

Company

  • About Us
  • Contact Us
  • Privacy Policy

© 2026 Luminys. All rights reserved.

Terms of ServicePrivacy Policy