Nhảy tới nội dung
Phiên bản: 2.3.0

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:
KeyTypeDescription
codestring[Bắt buộc] Mã người dùng
userNamestring[Bắt buộc] Tên đăng nhập
namestringHọ và Tên người dùng
emailstringEmail người dùng
phonestringSố điện thoại
groupIdsArray[int]Mảng Id nhóm người dùng
departmentIdsArray[int]Mảng Id bộ phận
roleIdsArray[Guild]Mảng Id vai trò
titleIdsArray[int]Mảng Id chức danh
taxcodestringMã số thuế
addressstringĐịa chỉ
faxstringSố fax
descriptionstringMô tả
signatureTextstringVăn bản ký mặc định
signConfirmationEnabledbooleanKý, phê duyệt sử dụng xác thực 2 lớp
generateSelfSignedCertEnabledbooleanTạo chữ ký số tự tạo
statusintTrạng thái người dùng
1: Hoạt động
-1: Ngưng hoạt động
receiveOtpMethodintPhương pháp nhận OTP
1: Email
2: SMS
-1: Không có
receiveNotificationMethodintPhương pháp nhận thông báo chứng từ
0: Email
1: SMS
-1: Không có
signMethodintPhương pháp ký
2: VNPT Smart CA
3: Ký số USB Token
receiveInfoAccountMethodintPhươ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​

KeyTypeDescription
successbooleanTrạng thái phản hồi của yêu cầu (true: Thành công, false: Thất bại)
codeintMã phản hồi từ hệ thống
messagesarrayDanh 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."])
dataarrayDanh 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)