Use this REST API to manage and administer leaves. With this resource, you can retrieve leaves lists, approve, reject, leave balance and policies in your WebWork account.
Below we provide an example of the data which is required for each scenario.
You can get all the leaves in your workspace with the following URL request
Copy code GET https://www.webwork-tracker.com/rest-api/leaves
Retrieves a list of leaves in your workspace. By default, results are paginated (50 rows per page). You can optionally filter leaves by including any combination of the following query parameters.
Copy code GET https://www.webwork-tracker.com/rest-api/leaves?id={id}&user_id={user_id}&policy_id={policy_id}&is_paid={yes | no}&status={pending | approved | rejected }&date_from={date_from}&date_to={date_to}&page={page}
The response returns a json format. Below you can see an example of response structure.
Copy code max_rows: "{max_rows}" current_page: "{current_page}" total_pages: "{total_pages}" data: [ { "id": "{id}" "user_id": "{user_id}" "status": "{status}" "note": "{note}" "is_paid": "{is_paid}" "created_by": "{created_by}" "approved_by": "{approved_by}" "rejected_by": "{rejected_by}" "reject_reason": "{reject_reason}" "start_date": "{start_date}" "end_date": "{end_date}" "created_on": "{created_on}" "total": { "days": "{days}", "hours": "{hours}" } }, {...} ]
If you need to approve a specific pending leave request, append the {id} at the end of the URL
Copy code PUT https://www.webwork-tracker.com/rest-api/leaves/approve/{id}
The returned response includes a success property which contains your request success value.
{ "success": "{success_of_the_request}" }
You can reject a pending leave request using the
Copy code PUT https://www.webwork-tracker.com/rest-api/leaves/reject/{id}
You should add the following header in your request
Copy code Content-Type: application/x-www-form-urlencoded
The list of parameters you can give to body
Property name | Type | Is required |
---|---|---|
reason | string | YES |
The returned response includes a success
property which contains your request
success value.
Copy code { "success": "{success_of_the_request}" }
You can get all the leaves balances in your workspace with the following URL request
Copy code GET https://www.webwork-tracker.com/rest-api/leaves/balances?date_from={date_from}&date_to={date_to}
Retrieves a list of leaves in your workspace. By default, results are paginated (50 rows per page), and you can optionally filter balances by including any combination of the following query parameters.
Copy code GET https://www.webwork-tracker.com/rest-api/leaves/balances?date_from={date_from}&date_to={date_to}&page={page}&user_id={user_id}
The response returns a json format. Below you can see an example of response structure.
Copy code max_rows: "{max_rows}" current_page: "{current_page}" total_pages: "{total_pages}" data: [ { "user_id": "{user_id}", "balances": [ { "policy_id": "{policy_id}", "policy_name": "{policy_name}", "used": { "days": "{days}", "hours": "{hours}" }, "balance": { "days": "{days}", "hours": "{hours}" } } ] }, {...} ]
You can get all the leaves policies in your workspace with the following URL request
Copy code GET https://www.webwork-tracker.com/rest-api/leaves/policies
Retrieves a list of leaves in your workspace. By default, results are paginated (50 rows per page), and you can optionally filter policies by including any combination of the following query parameters.
Copy code GET https://www.webwork-tracker.com/rest-api/leaves/policies?id={id}&page={page}
The response returns a json format. Below you can see an example of response structure.
Copy code max_rows: "{max_rows}" current_page: "{current_page}" total_pages: "{total_pages}" data: [ { "id": "{id}", "policy_name": "{policy_name}", "balance_schedule": "{balance_schedule}", "time_unit": "{time_unit}", "working_hours_per_day": "{working_hours_per_day}", "duration": { "days": "{days}", "hours": "{hours}" }, "paid": "{paid}", "is_negative_balance_allowed": "{is_negative_balance_allowed}", "reason_required": "{reason_required}" }, {...} ]