Appearance
API nhân viên
Dành cho Admin công ty. Dữ liệu tự giới hạn theo công ty của API key; client không truyền company_id.
Endpoint
| Method | Path | Scope | Chức năng |
|---|---|---|---|
GET | /api/v1/employees | platform.employee.read | Danh sách nhân viên. |
POST | /api/v1/employees | platform.employee.manage | Tạo nhân viên. |
GET | /api/v1/employees/{employeeId} | platform.employee.read | Đọc chi tiết nhân viên. |
PATCH | /api/v1/employees/{employeeId}/profile | platform.employee.manage | Cập nhật hồ sơ đầy đủ. |
PATCH | /api/v1/employees/{employeeId}/status | platform.employee.manage | Khóa hoặc mở tài khoản. |
PUT | /api/v1/employees/{employeeId}/roles | platform.employee.manage | Thay toàn bộ vai trò nghiệp vụ. |
Đọc dữ liệu
bash
curl --fail-with-body \
-H "Authorization: Bearer $NEXUS_API_KEY" \
"$NEXUS_URL/api/v1/employees"
curl --fail-with-body \
-H "Authorization: Bearer $NEXUS_API_KEY" \
"$NEXUS_URL/api/v1/employees/$EMPLOYEE_ID"Tạo nhân viên
roles phải chứa ít nhất một role nghiệp vụ đang hoạt động. Mật khẩu tối thiểu 12 ký tự.
bash
curl --fail-with-body -X POST \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"display_name": "Nguyễn Văn A",
"login_name": "nguyenvana",
"password": "ChangeMe-12345",
"roles": ["business.sales"]
}' \
"$NEXUS_URL/api/v1/employees"Cập nhật hồ sơ
Body là hồ sơ đầy đủ, không phải partial patch. Dùng chuỗi rỗng để xóa trường không bắt buộc.
bash
curl --fail-with-body -X PATCH \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"display_name": "Nguyễn Văn A",
"email": "a@example.com",
"phone": "0900000000",
"address": "TP. Hồ Chí Minh",
"gender": "male"
}' \
"$NEXUS_URL/api/v1/employees/$EMPLOYEE_ID/profile"gender nhận male, female, other hoặc chuỗi rỗng.
Khóa hoặc mở tài khoản
bash
curl --fail-with-body -X PATCH \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"status":"suspended"}' \
"$NEXUS_URL/api/v1/employees/$EMPLOYEE_ID/status"status nhận active hoặc suspended. Khóa tài khoản sẽ thu hồi các phiên Web và OAuth hiện tại.
Gán vai trò
PUT thay toàn bộ role nghiệp vụ hiện tại của nhân viên.
bash
curl --fail-with-body -X PUT \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"roles":["business.sales","business.support"]}' \
"$NEXUS_URL/api/v1/employees/$EMPLOYEE_ID/roles"