API 教学

WEMS HRM API 对接

提供企业系统对接 HRM 的基本规格、验证方式、端点示例与测试入口。

快速开始

正式 API Base URL:

https://hrm.sun-bd.com

公开整合信息:

GET https://hrm.sun-bd.com/api/v1/public/integration

Swagger:

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.html

API 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/employeesemployee.read
考勤资料GET /api/v1/attendanceattendance.read
请假资料GET /api/v1/leaveleave.read
文档资料GET /api/v1/documentsdocument.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原因处理
401token 或 API Key 无效重新登录或更换有效密钥。
403集中权限或 API Key 权限不足确认会员中心权限或 API Key scope。
429超过频率限制依响应延后重试。
5xx服务端错误记录时间、端点与 traceId 后回报。