QHR Developers

File a leave request on behalf of an employee

POST/employees/{id}/time_off/leave_requests
Needs a read & write tokenSubmit leave requests on behalf of employees time_off/request_on_behalfRequires feature time_offAvailable in Claudetime_off.create_leave_request

Files 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

NameInTypeDescriptionExample
idRequiredpathintegerEmployee id, from employees.list, employees.search or hr_leaves.employees.1203
Accept-LanguageheaderstringLanguage of messages and translated labels. English when omitted.
Allowed values: ar, en
ar

Request body

application/json

FieldTypeDescription
leave_requestRequiredobjectThe request.
leave_request.leave_policy_idRequiredintegerThe policy, from time_off.balances (id).
leave_request.start_dateRequiredstring (date)First day of leave.
leave_request.end_dateRequiredstring (date)Last day of leave.
leave_request.reasonstringWhy, up to 500 characters; approvers see it.

Response

201 The new request, pending approval. `warning` appears when it overlaps another pending request.

FieldTypeDescription
recordRequiredobjectThe leave request.
record.idintegerLeave request id.
record.employee_idintegerThe employee.
record.leave_policy_idintegerThe policy.
record.start_datestring (date)First day.
record.end_datestring (date)Last day.
record.balancestringWorking days it takes, as a decimal string.
record.reasonstringThe reason given.
record.statusstringAlways pending here.
record.on_behalfbooleanAlways true here.
record.created_atstringWhen it was filed, in UTC.
warningstringAdvice that did not stop the filing: an overlap with a pending request, or a booking in next year's balance.

Errors

HTTPCodeMeaningHow to fix
400bad_requestA parameter is missing or malformed.Check the parameters against this operation's documentation.
401token_missingNo Authorization: Bearer … header, or it is malformed.Send Authorization: Bearer qhr_… with the full token.
401token_invalidThe 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.
401token_expiredThe token is past its expiry date.Create a new token.
401token_revokedThe 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.
401tenant_inactiveThe company account is suspended.Contact QHR support.
403token_read_onlyThis token can only read; the operation makes changes.Use a token created with "Allow changes".
403forbiddenThe token owner's role lacks the permission this operation needs.Ask an admin to grant the permission shown on this operation (x-permission).
403employee_inactiveThe token owner's employee record is not active.HR must reactivate the employee record.
403tenant_access_revokedThe 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.
404not_foundThe record does not exist, or you cannot see it.Check the id. List the records first to get a valid one.
422validation_failedDates 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.
This endpoint can also return the errors that can happen on any endpoint →402 / 412 / 425 entitlement_blocked · 429 rate_limited · 500 internal_error

See the full error catalogue →