快速開始
正式 API Base URL:
https://hrm.sun-bd.com公開整合資訊:
GET https://hrm.sun-bd.com/api/v1/public/integrationSwagger:
https://hrm.sun-bd.com/swagger公開頁面與教學不需要登入;HRM 業務資料 API 需要集中會員 token 或 API Key。
集中會員 API
會員登入、登出、refresh、會員權限與 JWKS 都集中在會員 API 管理。本專案不建立會員、不修改會員資料,也不自行簽發會員 token。
POST https://hrm.sun-bd.com/api/v1/member-auth/login
POST https://hrm.sun-bd.com/api/v1/member-auth/refresh
POST https://hrm.sun-bd.com/api/v1/member-auth/logout
GET https://hrm.sun-bd.com/api/v1/member-auth/me/permissions瀏覽器端使用 HRM 同網域代理,再由後端轉呼叫集中會員 API,避免跨網域限制。集中會員 API 教學:
https://loginapi.sun-bd.com/docs/integration/member-login-logout.htmlAPI Key
企業後端系統可使用 HRM API Key 呼叫外部對接 API。
X-API-Key: whrm_xxxxxxxxxxxxxxxxxxxxx- API Key 僅用於系統對系統串接。
- 一般使用者登入仍由集中會員 API 管理。
- 權限不足回 403,金鑰錯誤或過期回 401。
常用端點
| 功能 | 端點 | 權限 |
|---|---|---|
| 健康檢查 | GET /api/health | 公開 |
| 整合資訊 | GET /api/v1/public/integration | 公開 |
| 員工資料 | GET /api/v1/employees | employee.read |
| 出勤資料 | GET /api/v1/attendance | attendance.read |
| 請假資料 | GET /api/v1/leave | leave.read |
| 薪資批次 | GET /api/v1/payroll-runs | payroll.read |
| 文件資料 | GET /api/v1/documents | document.read |
程式範例
JavaScript
const response = await fetch("https://hrm.sun-bd.com/api/v1/employees?page=1&pageSize=20", {
headers: { "X-API-Key": process.env.WEMS_HRM_API_KEY }
});
if (!response.ok) throw new Error(`HRM API failed: ${response.status}`);
const body = await response.json();PowerShell
$headers = @{ "X-API-Key" = $env:WEMS_HRM_API_KEY }
Invoke-RestMethod -Method Get -Uri "https://hrm.sun-bd.com/api/v1/employees" -Headers $headers錯誤處理
| HTTP | 原因 | 處理 |
|---|---|---|
| 401 | token 或 API Key 無效 | 重新登入或更換有效金鑰。 |
| 403 | 集中權限或 API Key 權限不足 | 確認會員中心權限或 API Key scope。 |
| 429 | 超過頻率限制 | 依回應延後重試。 |
| 5xx | 服務端錯誤 | 記錄時間、端點與 traceId 後回報。 |