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

Tạo mới 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 thông tin người dùng và tài khoản đăng nhập hệ thống.

  • Request URL: /api/users/create
  • 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
namestring[Bắt buộc] Họ và Tên người dùng
emailstring[Bắt buộc] Email người dùng
phonestring[Bắt buộc] Số điện thoại
addressstringĐịa chỉ người dùng
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ò
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": "Quan 3, TP.Ho Chi 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"]
}

Mẫu response body​

{
"data": {
"id": 4401,
"createdDate": "2022-12-13T14:55:32.2867265+07:00",
"comId": 164,
"code": "USER01",
"name": "Nguyen Van A",
"phone": "0919XXXXXX",
"taxcode": "1234567890",
"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": "75d5d881-9a88-40ea-9eca-5e370a087e3a",
"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 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 trả về từ hệ thống (ví dụ: ["Create user success"])
dataobjectĐối tượng chứa thông tin chi tiết người dùng vừa tạo thành công (xem chi tiết thông tin người dùng)

Các lỗi thường gặp​

MessageDescription
Username 'username' is already takenUsername đã tồn tại trong hệ thống
User code 'usercode' already exists in the companyUser Code đã tồn tại trong hệ thống