Appearance
API công ty
Chỉ Super Admin sử dụng nhóm API này.
Endpoint
| Method | Path | Scope | Chức năng |
|---|---|---|---|
GET | /api/v1/companies | platform.company.manage | Danh sách, tìm kiếm và lọc công ty. |
POST | /api/v1/companies | platform.company.manage | Tạo công ty cùng Admin đầu tiên. |
GET | /api/v1/companies/{companyId} | platform.company.manage | Chi tiết công ty. |
PATCH | /api/v1/companies/{companyId}/status | platform.company.manage | Khóa hoặc mở công ty. |
POST | /api/v1/companies/{companyId}/admins | platform.company.manage | Tạo thêm Admin công ty. |
PATCH | /api/v1/companies/{companyId}/admins/{employeeId}/status | platform.company.manage | Khóa hoặc mở Admin. |
PUT | /api/v1/companies/{companyId}/packages | platform.company.package.manage | Thay toàn bộ Package được cấp. |
Danh sách, tìm kiếm và lọc
bash
curl --fail-with-body \
-H "Authorization: Bearer $NEXUS_API_KEY" \
"$NEXUS_URL/api/v1/companies"
curl --fail-with-body --get \
-H "Authorization: Bearer $NEXUS_API_KEY" \
--data-urlencode "q=acme" \
--data-urlencode "status=active" \
"$NEXUS_URL/api/v1/companies"q tối đa 100 ký tự. status hiện dùng active hoặc suspended.
Tạo công ty
bash
curl --fail-with-body -X POST \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"code": "acme-corp",
"display_name": "Công ty Acme",
"admin_display_name": "Admin Acme",
"admin_login_name": "admin.acme",
"admin_password": "ChangeMe-12345",
"packages": ["sales.employee.tools"]
}' \
"$NEXUS_URL/api/v1/companies"Tạo thêm Admin
bash
export COMPANY_ID="00000000-0000-4000-8000-000000000101"
curl --fail-with-body -X POST \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"display_name":"Admin thứ hai","login_name":"admin.acme2","password":"ChangeMe-12345"}' \
"$NEXUS_URL/api/v1/companies/$COMPANY_ID/admins"Cấp Package cho công ty
PUT thay toàn bộ danh sách Package hiện tại.
bash
curl --fail-with-body -X PUT \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"packages":["sales.employee.tools","support.employee.tools"]}' \
"$NEXUS_URL/api/v1/companies/$COMPANY_ID/packages"Trạng thái công ty hoặc Admin
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/companies/$COMPANY_ID/status"Body trạng thái nhận active hoặc suspended. Endpoint Admin dùng cùng body tại /companies/{companyId}/admins/{employeeId}/status.