Department

This article contains APIs to use information about the existing departments as well as to create a new department.

Department refers to a specific division of an organization.  You can use any of the following APIs to get or set department information. 

Get All departments

GET /xDepartment

This API is used to retrieve all the departments in the organization.

For example,

GET https://corehr-api.hrcloud.com/v1/cloud/xDepartment

Response:

[
{
"Id": "a7384a1617ed78577db54b4ede762cc6",
"xDepartmentCode": "HR",
"xDepartmentName": "Human Resources",
"xOverheadDepartment": null,
"xRecordStatus": "Active"
},
{
"Id": "1249a68e0462d50d",
"xDepartmentCode": "FIN",
"xDepartmentName": "Finance",
"xOverheadDepartment": null,
"xRecordStatus": "Active"
},
{
"Id": "0ed631731310ac7503b711f4cdd7dc3f",
"xDepartmentCode": "HR",
"xDepartmentName": "Human Resources",
"xOverheadDepartment": null,
"xRecordStatus": "Active"
},
...
]

Get a particular Department

GET /xDepartment/:departmentId

Retrieve the details of a department using the Id.

For example,

GET https://corehr-api.hrcloud.com/v1/cloud/xDepartment/a7384a1617ed78577db54b4ede762cc6

Response:

[
{
"Id": "a7384a1617ed78577db54b4ede762cc6",
"xDepartmentCode": "HR",
"xDepartmentName": "Human Resources",
"xOverheadDepartment": null,
"xRecordStatus": "Active"
}
]

Create a new department

POST /xDepartment

This API can be used to create a new department. Following input parameters are used to create a new department.

Field Name Type Description Mandatory
xDepartmentCode String Unique alpha-numeric identifier for the department Yes
xDepartmentName String Name of the department Yes
xRecordStatus String Active or Inactive Yes

For example:

POST https://corehr-api.hrcloud.com/v1/cloud/xDepartment

Input parameters:

{
"xDepartmentName": "Payroll",
"xDepartmentCode": "PAY",
"xRecordStatus": "Active"
}

Response on success:

Status: 200 OK 

Update an existing department

PUT /xDepartment

Updates information for a specific department. The fields to be modified should be provided as input parameters. To identify the department to be updated, use one of the following ways. 

1. Provide the unique Id for the department along with the input parameters. 

For example, 

PUT https://corehr-api.hrcloud.com/v1/cloud/xDepartment

Input Parameters:

 {
"Id": "482fb76dfd1b8c3ada2bdcb05a7335ae",
"xDepartmentName": "Finance - Payroll",
"xDepartmentCode": "FIN1",
}

Response:

[
{
"Id": "482fb76dfd1b8c3ada2bdcb05a7335ae",
"xDepartmentCode": "FIN1",
"xDepartmentName": "Finance - Payroll",
"xOverheadDepartment": null,
"xRecordStatus": "Active"
}
]

2. Use a unique field in the url to identify a particular record. In this case, ID is not used in the input parameters. Instead the field value is used to search for the record.

For example, 

Request

PUT https://corehr-api.hrcloud.com/v1/cloud/xDepartment?Identifier=xDepartmentCode

Input parameters:

{
"xDepartmentCode": "HR",
"xDepartmentName": "Human Resource - New York"
}