快速开始
正式 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/documents | document.read |
程序示例
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();错误处理
| HTTP | 原因 | 处理 |
|---|---|---|
| 401 | token 或 API Key 无效 | 重新登录或更换有效密钥。 |
| 403 | 集中权限或 API Key 权限不足 | 确认会员中心权限或 API Key scope。 |
| 429 | 超过频率限制 | 依响应延后重试。 |
| 5xx | 服务端错误 | 记录时间、端点与 traceId 后回报。 |