Add Employee User Account
เพิ่มบัญชีผู้ใช้ระบบให้กับพนักงาน
Endpoint
POST /api/v1/open-apis/employee/add-employee-setting?path_action=userQuery Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
path_action | string | Yes | ต้องเป็น user |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
employee_code | string | Yes | รหัสพนักงาน |
username | string | Yes | ชื่อผู้ใช้สำหรับเข้าสู่ระบบ |
password | string | Yes | รหัสผ่าน |
user_groups | array | No | รายการกลุ่มผู้ใช้ที่ต้องการกำหนด |
ใช้ employee_code เพื่อระบุพนักงาน
Response Format
Success Response
{
"code": 200,
"message": "Add User Success",
"payload": {
"employee_id": "20260121EM01A2B3C4D5",
"username": "emp001@company.com",
"user_groups": ["employee"]
}
}Error Response
{
"code": 400,
"message": "Validation failed",
"errors": [
"Missing required parameter: 'username'",
"Missing required parameter: 'password'"
]
}Validation Rules
| Field | Rule |
|---|---|
employee_code | ต้องระบุและต้องมีพนักงานในระบบ |
username | ต้องระบุและต้องไม่ซ้ำกับ username อื่นในระบบ |
password | ต้องระบุและต้องมีความยาวตามที่ระบบกำหนด |
user_groups | ต้องเป็น array และกลุ่มผู้ใช้ต้องมีอยู่ในระบบ |
Code Examples
cURL
curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/employee/add-employee-setting?path_action=user" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
-d '{
"employee_code": "EMP001",
"username": "emp001@company.com",
"password": "SecurePass123!",
"user_groups": ["employee", "sales"]
}'Notes
- พนักงานหนึ่งคนสามารถมีบัญชีผู้ใช้ได้เพียงบัญชีเดียว
- หากต้องการเปลี่ยน username ให้ใช้ Reset Username
- หากต้องการเปลี่ยนรหัสผ่านให้ใช้ Reset Password
รหัสผ่านควรมีความปลอดภัยและเป็นไปตามนโยบายรหัสผ่านขององค์กร
Related APIs
- Get User - ดึงข้อมูลบัญชีผู้ใช้
- Delete User - ลบบัญชีผู้ใช้
- Update Groups - แก้ไขกลุ่มผู้ใช้
- Reset Password - รีเซ็ตรหัสผ่าน
- Reset Username - รีเซ็ต username
Last updated on