Location

This article explains all the APIs to view or edit existing locations as well as create new locations.

Locations are the workplace locations of the employees of an organization across different regions.

Get All Locations

GET /xLocation

Retrieves all the existing locations. 

For example,

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

Response:

[
{
"Id": "3b231262293a8c76b0e656172021dfea",
"xAddress": "Karnataka, India",
"xDescription": "<p>Documentation office</p>",
"xLocationCode": "BLR",
"xLocationName": "Bangalore",
"xRecordStatus": "Active"
},
{
"Id": "ae4bc130b51576be48c2a0f4752e8b31",
"xAddress": "Vietnam",
"xDescription": "Web development",
"xLocationCode": "e6a7b307-d12c-438b-8f1d-b082a194dd7a",
"xLocationName": "Vietnam",
"xRecordStatus": "Active"
},
{
"Id": "6035d64a4202ca7a6178ae8fa6dc0a44",
"xAddress": "Denver",
"xDescription": "Marketing office",
"xLocationCode": "4821bf69-7af9-4915-87e9-486cb1b01cbd",
"xLocationName": "Denver",
"xRecordStatus": "Active"
},
...
]

Get details of a particular Location

GET /xLocation/:locationId

Retrieves the details of a particular location using the specific location Id.

For example,

GET https://corehr-api.hrcloud.com/v1/cloud/xLocation/6035d64a4202ca7abcce78a8ab4c9c52

Response:

[
{
"Id": "6035d64a4202ca7abcce78a8ab4c9c52",
"xAddress": "LA",
"xDescription": "Marketing Office",
"xLocationCode": "f40de2d6-ab8f-433e-8600-a738c0663a42",
"xLocationName": "Los Angeles - NGV",
"xRecordStatus": "Active"
}
]

Create a new location

POST /xLocation

Creates a new location.

This API takes the following input parameters.

Name Type Description Mandatory
xLocationCode String Unique alpha-numeric code for location Yes
xLocationName String Name of location Yes
xRecordStatus String Active or Inactive Yes
xDescription String Description of location No
xAddress String Complete address of the location No

For example, 

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

Input parameters:

{
"xLocationCode": "ANC",
"xLocationName": "Anchorage",
"xRecordStatus": "Active"
}

Response:

[
{
"Id": "7a9374b0c241f2520ea7168f077bc288",
"xAddress": null,
"xDescription": null,
"xLocationCode": "ANC",
"xLocationName": "Anchorage",
"xRecordStatus": "Active"
}
]

Update a location

PUT /xLocation

Updates an existing location. 

You can either use the location id to update the location or use any of the other location fields to update. Please note that in any case, the location Id cannot be updated. 

1. Update using location Id - Provide the location Id in the input parameters. For example,

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

Input parameters:

{
"Id": "7a9374b0c241f2520ea7168f077bc288",
"xDescription": "Processing Center"
}

 Response:

[
{
"Id": "7a9374b0c241f2520ea7168f077bc288",
"xAddress": null,
"xDescription": "Processing Center",
"xLocationCode": "ANC",
"xLocationName": "Anchorage",
"xRecordStatus": "Active"
}
]

2. Update using a specific field - In this case, use a field in the method ( such as ?Identifier=xLocationCode) to select the record to be updated.

Please note that only a unique field can be used to identify  a record for update. Also do not provide the Id field in the input parameters to this API.

For example, in this case, xLocationCode is a unique field.

PUT https://corehr-api.hrcloud.com/v1/cloud/xLocation?Identifier=xLocationCode

Input parameters:

[
{
"xDescription": "Documentation - Remote ",
"xLocationCode": "BLR"
}
]