Create user
Updated date: 18/09/2026
Updated by: VNPT eContract's team
Purpose
Function to create new user information and login account for the system.
- Request URL:
/api/users/create - HTTP method:
POST - HTTP content-type:
application/json - Authorize:
Bearer token - Parameter:
| Key | Type | Description |
|---|---|---|
code | string | [Required] Code of user |
username | string | [Required] Username of user |
name | string | [Required] Full Name of user |
email | string | [Required] Email of user |
phone | string | [Required] Phone number |
address | string | Address of user |
groupIds | Array[int] | Array of group user Ids |
departmentIds | Array[int] | Array of department Ids |
roleIds | Array[Guild] | Array of role Ids |
titleIds | Array[int] | Array of title Ids |
taxcode | string | Tax code of user |
address | string | Address of user |
fax | string | Fax number of user |
description | string | Description |
signatureText | string | Default signature text |
signConfirmationEnabled | boolean | Sign, approve using two-factor authentication |
generateSelfSignedCertEnabled | boolean | Generate Self-signed certificate |
status | int | Status of user 1: Enabled -1: Disabled |
receiveOtpMethod | int | Receive OTP method 1: Email 2: SMS -1: None |
receiveNotificationMethod | int | Receive document notification method 0: Email 1: SMS -1: None |
signMethod | int | Sign method 2: VNPT Smart CA 3: Sign Token |
receiveInfoAccountMethod | int | Receive account information 0: Email 1: SMS -1: None |
caution
- When creating a new user, all required fields must be provided, including roleIds and departmentIds.
- For subsequent update calls, a partial payload can be sent (only the fields that need to be updated).
- Fields that are not included in the request will retain their current values (will not be set to null).
Sample request
{
"code": "USER01",
"username": "your_username",
"name": "Nguyen Van A",
"email": "email_address",
"address": "user_address",
"phone": "0919XXXXXX",
"taxcode": "1234567890",
"address": "District 3, Ho Chi Minh City",
"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]
}
Sample 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": "Default",
"description": "Default role with document processing permissions",
"roleLevel": 0
}
],
"departments": [
{
"id": 1,
"name": "Human Resources",
"code": "HR"
}
],
"groups": [
{
"id": 1,
"code": "USER_GRP",
"name": "User Group"
}
],
"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": "Chief Accountant",
"description": "Chief Accountant"
}
],
"allowedCertificateUids": []
},
"success": true,
"code": 0,
"messages": [
"Create user success"
]
}
Response Body Description
| Key | Type | Description |
|---|---|---|
success | boolean | Response status (true: Success, false: Failure) |
code | int | Response code from the system |
messages | array | List of messages returned by the system (e.g., ["Create user success"]) |
data | object | Object containing detailed information about the successfully created user (see user details) |
Common Errors
| Message | Description |
|---|---|
Username 'username' is already taken | The username already exists in the system |
User code 'usercode' already exists in the company | The user code already exists in the system |