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:
| 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 | [Bắt buộc] Họ và Tên người dùng |
email | string | [Bắt buộc] Email người dùng |
phone | string | [Bắt buộc] Số điện thoại |
address | string | Địa chỉ người dùng |
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ò |
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": "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
| 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 trả về từ hệ thống (ví dụ: ["Create user success"]) |
data | object | Đố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
| Message | Description |
|---|---|
Username 'username' is already taken | Username đã tồn tại trong hệ thống |
User code 'usercode' already exists in the company | User Code đã tồn tại trong hệ thống |