Skip to main content
Version: 2.3.0

Create or update department

Updated date: 01/10/2026
Updated by: VNPT eContract's team


Purpose​

The function creates new departments or updates existing departments identified by department code. Multiple departments can be processed in one request.

  • Request URL: /api/departments/create-or-update
  • HTTP method: POST
  • HTTP content-type: application/json
  • Authorize: Bearer token
  • Parameter:

The request body is an array of department objects with the following fields:

KeyTypeRequiredDescription
codestringYesUnique department code. If the code already exists, the corresponding department is updated.
namestringYesDepartment name.
descriptionstringNoDepartment description.
sharingAccessPermissionbooleanNoWhether users in the department share access permissions.
userCodesArray[string]NoCodes of users assigned to the department.

Sample request​

[
{
"code": "HR",
"name": "Human Resources",
"description": "",
"sharingAccessPermission": false,
"userCodes": ["USER01"]
},
{
"code": "IT",
"name": "Information Technology",
"description": "",
"sharingAccessPermission": false,
"userCodes": []
}
]

Sample response body​

{
"data": [
{
"id": 12012,
"name": "Human Resources",
"code": "HR",
"userCount": 1,
"sharingAccessPermission": false,
"users": [],
"requireApproval": false
},
{
"id": 12013,
"name": "Information Technology",
"code": "IT",
"userCount": 0,
"sharingAccessPermission": false,
"users": [],
"requireApproval": false
}
],
"success": true,
"code": 0,
"messages": [
"Create 2 department success, update 0 department success."
]
}

Response Body Description​

KeyTypeDescription
successbooleanResponse status (true: Success, false: Failure).
codeintResponse code from the system.
messagesarrayList of messages summarizing the number of departments created and updated.
dataarrayList of newly created or updated departments (see details below).

Details of objects in the data array:​

KeyTypeDescription
idintDepartment ID.
namestringDepartment name.
codestringDepartment code.
userCountintNumber of users assigned to the department.
sharingAccessPermissionbooleanWhether users in the department share access permissions.
usersarrayList of users in the department.
requireApprovalbooleanWhether approval is required for the department.