Skip to main content
Panguard AI 提供三個獨立的 API 服務。每個服務運行在自己的埠上,處理不同的功能領域。

API 服務

Auth Server API

Port 3000 — 使用者註冊、登入、工作階段、TOTP 雙因素驗證、GDPR 合規和訂閱管理。

Manager API

Port 8443 — 代理註冊、心跳、威脅事件接收、策略管理、SSE 串流和機群儀表板。

Threat Cloud API

可設定埠 — IoC 管理、威脅摘要、攻擊活動追蹤、MITRE 熱力圖、地理查詢和稽核日誌。

基礎 URL

服務預設基礎 URLTLS
Auth Serverhttps://auth.panguard.aihttp://localhost:3000選用(建議使用)
Managerhttps://localhost:8443預設為自簽憑證
Threat Cloudhttps://tc.panguard.aihttp://localhost:PORT選用

身份驗證

所有需認證的端點都需要在 Authorization 標頭中提供 Bearer token
curl -X GET https://localhost:8443/api/agents \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
Manager API 使用透過 MANAGER_AUTH_TOKEN 環境變數設定的共享靜態 token。Auth Server API 在登入時簽發 JWT token。

通用回應格式

每個 API 端點都回傳一致的 JSON 封套:
{
  "ok": true,
  "data": {
    "id": "agent-001",
    "hostname": "web-server-1"
  }
}

速率限制

所有 API 服務都實施速率限制以防止濫用。
服務預設限制範圍
Auth Server20 次請求/分鐘每個 IP
Manager API60 次請求/分鐘每個 IP
Threat Cloud因端點而異每個 API key
當受到速率限制時,API 回傳 429 狀態碼,並附帶 Retry-After 標頭指示何時可以重試。

錯誤碼

狀態碼意義說明
200OK請求成功
201Created資源建立成功
400Bad Request無效的請求主體或缺少必要欄位
401Unauthorized缺少或無效的身份驗證 token
403ForbiddenToken 有效但權限或方案層級不足
404Not Found請求的資源不存在
429Too Many Requests超出速率限制,請檢查 Retry-After 標頭
500Internal Server Error非預期的伺服器錯誤,請以退避方式重試

內容類型

除非另有說明,所有請求和回應主體都使用 application/json。摘要端點可能會回傳 text/plain 用於封鎖清單格式。

分頁

回傳集合的端點支援透過查詢參數進行分頁:
page
number
default:"1"
頁碼(從 1 開始)。
limit
number
default:"50"
每頁項目數。最大 200。
分頁回應包含中繼資料:
{
  "ok": true,
  "data": [...],
  "pagination": {
    "total": 342,
    "page": 1,
    "limit": 50,
    "pages": 7
  }
}

下一步