Departments and Units Endpoint Usage
Endpoint:GET https://api-sandbox.seamlesshr.app/v1/companies/departments
This endpoint can be used to retrieve company departments, units, or both departments and units in a single request. The data returned depends on the query parameters supplied.
Required Parameter
company(Required): Specifies the company whose departments or units you want to retrieve. This parameter must be included in every request.
Optional Query Parameters
tag: Specifies the type of data to retrieve. It acceptsdepartmentorunit.department_code: Used to retrieve a specific unit by its department code, in combination with the company and appropriate tag.
Usage Examples
1. Get all departments
Retrieve departments belonging to a company by setting the tag to department.
GET /v1/companies/departments?company=Integration Company&tag=department
2. Get all units
Retrieve units belonging to a company by setting the tag to unit.
GET /v1/companies/departments?company=Integration Company&tag=unit
3. Get a unit by department code
Retrieve a unit using its department code by providing the department_code parameter along with the company and tag=unit.
GET /v1/companies/departments?company=Integration Company&tag=unit&department_code=PepUnit
4. Get departments and units in the same request
The endpoint supports retrieving both departments and units in a single request by passing multiple tag values as indexed query parameters.
For example:
GET /v1/companies/departments?company=Integration Company&tag[0]=unit&tag[1]=department
In this example:
tag[0]=unitrequests units.tag[1]=departmentrequests departments.
This allows both types of data to be retrieved in one API call instead of making separate requests.
Important Notes
- The
companyparameter is mandatory for all requests. - The
tagparameter determines whether departments, units, or both are retrieved. - Use
department_codewhen you need to filter for a specific unit by its code. - When retrieving both departments and units, use indexed
tagparameters, such astag[0]andtag[1]. - Ensure query parameter values containing spaces, such as
Integration Company, are URL-encoded when making requests. For example, useIntegration%20Company.
