File a leave request on behalf of an employee
/employees/{id}/time_off/leave_requeststime_off/request_on_behalfRequires feature time_offAvailable in Claudetime_off.create_leave_requestFiles a leave request for an employee, as HR, under one of their leave policies. QHR counts the working days (weekends and holidays excluded) and the request starts pending, going through the policy's normal approval chain (manager, HR, or manager then HR) exactly as if the employee had filed it; it is not approved by being filed here. It is marked on_behalf, which lets it use past dates even when the policy does not. The employee cannot edit it, and if they cancel it the cancellation goes to the approver's review instead of taking effect at once.
When to use: when someone asks HR to book leave for them, or to record leave after the fact. Check the dates first with time_off.validate_leave_request. To file for yourself, use your own leave requests instead.
Prerequisites: the employee's id from employees.list; leave_policy_id from time_off.balances. Needs "Submit leave requests on behalf of employees".
Side effects: the days are held against the balance as pending (pending_days) until it is decided; each approver of the first stage is emailed. Refused when the days exceed the available balance (unless the policy allows a negative balance), when it overlaps leave already approved, or when it ends after the employee's last working day. A request that only overlaps another pending one is filed, with a warning. A policy that requires a supporting document cannot be filed here: the document is a file upload, which this operation does not take.
Before you call this
You will need ids that come from these operations:
Parameters
| Name | In | Type | Description | Example |
|---|---|---|---|---|
idRequired | path | integer | Employee id, from employees.list, employees.search or hr_leaves.employees. | 1203 |
Accept-Language | header | string | Language of messages and translated labels. English when omitted. Allowed values: ar, en | ar |
Request body
application/json
| Field | Type | Description |
|---|---|---|
leave_requestRequired | object | The request. |
leave_request.leave_policy_idRequired | integer | The policy, from time_off.balances (id). |
leave_request.start_dateRequired | string (date) | First day of leave. |
leave_request.end_dateRequired | string (date) | Last day of leave. |
leave_request.reason | string | Why, up to 500 characters; approvers see it. |
Response
201 The new request, pending approval. `warning` appears when it overlaps another pending request.
| Field | Type | Description |
|---|---|---|
recordRequired | object | The leave request. |
record.id | integer | Leave request id. |
record.employee_id | integer | The employee. |
record.leave_policy_id | integer | The policy. |
record.start_date | string (date) | First day. |
record.end_date | string (date) | Last day. |
record.balance | string | Working days it takes, as a decimal string. |
record.reason | string | The reason given. |
record.status | string | Always pending here. |
record.on_behalf | boolean | Always true here. |
record.created_at | string | When it was filed, in UTC. |
warning | string | Advice that did not stop the filing: an overlap with a pending request, or a booking in next year's balance. |
Errors
| HTTP | Code | Meaning | How to fix |
|---|---|---|---|
| 400 | bad_request | A parameter is missing or malformed. | Check the parameters against this operation's documentation. |
| 401 | token_missing | No Authorization: Bearer … header, or it is malformed. | Send Authorization: Bearer qhr_… with the full token. |
| 401 | token_invalid | The token is unknown or wrong, or its owner's account is locked. | Check the token was copied in full, or create a new one in QHR › Settings › API & Integrations. |
| 401 | token_expired | The token is past its expiry date. | Create a new token. |
| 401 | token_revoked | The token was revoked by its owner or an admin, or the owner was removed from the company (which revokes all their tokens). | Create a new token, or ask your admin. If the owner was removed, they must be re-invited to the company first. |
| 401 | tenant_inactive | The company account is suspended. | Contact QHR support. |
| 403 | token_read_only | This token can only read; the operation makes changes. | Use a token created with "Allow changes". |
| 403 | forbidden | The token owner's role lacks the permission this operation needs. | Ask an admin to grant the permission shown on this operation (x-permission). |
| 403 | employee_inactive | The token owner's employee record is not active. | HR must reactivate the employee record. |
| 403 | tenant_access_revoked | The token's owner is no longer an active member of this company. Rare: removing a member normally revokes their tokens, which answers 401 token_revoked instead. | The owner must be re-invited to the company, then create a new token. If the owner is still a member, contact QHR support. |
| 404 | not_found | The record does not exist, or you cannot see it. | Check the id. List the records first to get a valid one. |
| 422 | validation_failed | Dates missing, malformed or reversed; the policy is not held; no working days in the range; not enough balance; it overlaps approved leave; it ends after the last working day; or the policy needs a document. | Fix what error names. Check dates first with time_off.validate_leave_request. |
entitlement_blocked · 429 rate_limited · 500 internal_error