Tạo mới hoặc cập nhật người dùng
Ngày cập nhật: 18 tháng 09, 2026
Người cập nhật: VNPT eContract's team
Mục đích
Hàm thực hiện tạo mới hoặc cập nhật các thông tin của 1 hoặc nhiều người người dùng trong hệ thống.
- Request URL:
/api/users/create-or-update - HTTP method:
POST - HTTP content-type:
application/json - Authorize:
Bearer token - Parameter:
| Key | Type | Description |
|---|---|---|
code | string | [Bắt buộc] Mã người dùng |
userName | string | [Bắt buộc] Tên đăng nhập |
name | string | Họ và Tên người dùng |
email | string | Email người dùng |
phone | string | Số điện thoại |
groupIds | Array[int] | Mảng Id nhóm người dùng |
departmentIds | Array[int] | Mảng Id bộ phận |
roleIds | Array[Guild] | Mảng Id vai trò |
titleIds | Array[int] | Mảng Id chức danh |
taxcode | string | Mã số thuế |
address | string | Địa chỉ |
fax | string | Số fax |
description | string | Mô tả |
signatureText | string | Văn bản ký mặc định |
signConfirmationEnabled | boolean | Ký, phê duyệt sử dụng xác thực 2 lớp |
generateSelfSignedCertEnabled | boolean | Tạo chữ ký số tự tạo |
status | int | Trạng thái người dùng 1: Hoạt động -1: Ngưng hoạt động |
receiveOtpMethod | int | Phương pháp nhận OTP 1: Email 2: SMS -1: Không có |
receiveNotificationMethod | int | Phương pháp nhận thông báo chứng từ 0: Email 1: SMS -1: Không có |
signMethod | int | Phương pháp ký 2: VNPT Smart CA 3: Ký số USB Token |
receiveInfoAccountMethod | int | Phương pháp nhận thông tin tài khoản 0: Email 1: SMS -1: Không có |
cẩn thận
- Khi tạo mới user, bắt buộc phải truyền đầy đủ các thông tin cần thiết, bao gồm roleIds và departmentIds.
- Từ các lần gọi update tiếp theo, có thể truyền partial payload (chỉ các field cần cập nhật).
- Field không truyền sẽ giữ nguyên giá trị hiện tại (không bị null hóa)
Mẫu request
[
{
"code": "USER01",
"username": "your_username",
"name": "Nguyen Van A",
"email": "email_address",
"phone": "0919XXXXXX",
"taxcode": "1234567890",
"address": "Quận 3, TP.Hồ Chí Minh",
"fax": "123",
"description": "",
"signatureText": "",
"signConfirmationEnabled": true,
"generateSelfSignedCertEnabled": false,
"status": 1,
"receiveOtpMethod": 1,
"receiveNotificationMethod": 0,
"signMethod": 2,
"groupIds": [
1
],
"departmentIds": [
1
],
"roleIds": [
"30933485-7f71-46af-71a3-08def1dc25d3"
],
"titleIds":[
1
]
}
]
Mẫu response body
{
"data": [
{
"id": 8072,
"createdDate": "2023-06-28T14:31:30.9534748",
"comId": 164,
"code": "USER01",
"name": "Nguyen Van A",
"phone": "0919XXXXXX",
"email": "email_address",
"address": "user_address",
"identityVerificationStatus": {
"value": 0,
"description": "Not verified"
},
"identityVerifiedType": {
"value": 0,
"description": "Unknown"
},
"identityVerifiedSource": {
"value": 0,
"description": "Unknown"
},
"isValid": false,
"signConfirmationEnabled": true,
"isAccountLocked": false,
"accountId": "e06d8b9c-6f49-4751-87d0-6367c524a6ce",
"signatureText": "",
"roles": [
{
"id": "30933485-7f71-46af-71a3-08def1dc25d3",
"code": "Default",
"name": "Mặc định",
"description": "Vai trò mặc định với những quyền xử lý chứng từ",
"roleLevel": 0
}
],
"departments": [
{
"id": 1,
"name": "Quản lý nhân sự",
"code": "HR"
}
],
"groups": [
{
"id": 1,
"code": "USER_GRP",
"name": "Nhóm người dùng"
}
],
"signMethod": {
"value": 2,
"description": "VNPT Smart CA"
},
"status": {
"value": 1,
"description": "Enabled"
},
"receiveOtpMethod": {
"value": 1,
"description": "Email"
},
"receiveNotificationMethod": {
"value": 0,
"description": "Email"
},
"personalCertificateId": 5111,
"userCertificates": [],
"smartCaGroups": [],
"waitingChangeRequest": false,
"twoFactorEnabled": false,
"titles": [
{
"id": 1,
"code": "KTT",
"name": "Kế toán trưởng",
"description": "Kế toán trưởng"
}
],
"allowedCertificateUids": []
}
],
"success": true,
"code": 0,
"messages": [
"Create 0 user success, update 1 user success."
]
}
Mô tả Response Body
| Key | Type | Description |
|---|---|---|
success | boolean | Trạng thái phản hồi của yêu cầu (true: Thành công, false: Thất bại) |
code | int | Mã phản hồi từ hệ thống |
messages | array | Danh sách thông báo kết quả xử lý từ hệ thống (ví dụ: ["Create 0 user success, update 1 user success."]) |
data | array | Danh sách đối tượng chứa thông tin chi tiết các người dùng vừa được tạo mới hoặc cập nhật (xem chi tiết thông tin người dùng) |