QHR Developers

Cancel my leave request

PATCH/leave_requests/{id}/cancel
Needs a read & write tokenCancel leave requests leave_request/cancelRequires feature leave_requestAvailable in Claudeleave_requests.cancel

Cancels one of the token owner's own leave requests. What happens depends on how far it got:

- Still waiting, and no manager has approved it yet: cancelled at once (status: cancelled). - Approved, or already approved by the manager and waiting for HR, or filed for you by HR or the manager: becomes a cancellation request for the approver (current_stage: cancellation_review); the leave stands until they decide with leave_requests.approve_cancellation or leave_requests.reject_cancellation. Cancelling an approved leave needs a note.

Refused (422) once the leave has started, when it was already rejected, cancelled or revoked, or while an earlier cancellation is under review.

When to use: when a person no longer needs leave they asked for. To change the dates of a request no one has decided yet, leave_requests.update keeps it in the queue instead.

Prerequisites: the request's id from leave_requests.list (check locked / lock_reason there).

Side effects: a direct cancellation gives the reserved days back at once and emails the approvers that it was withdrawn. A cancellation request emails the approvers asking them to review it; the days come back only when they approve it. Recorded in the request's history and the audit log.

Before you call this

You will need ids that come from these operations:

Parameters

NameInTypeDescriptionExample
idRequiredpathintegerLeave request id, from leave_requests.list (your own) or team_leaves.pending_requests (your team's).5120
Accept-LanguageheaderstringLanguage of messages and translated labels. English when omitted.
Allowed values: ar, en
ar

Request body

application/json

FieldTypeDescription
notestringThe reason, up to 500 characters. Required when the leave is approved.

Response

200 The request after the cancellation.

FieldTypeDescription
recordRequiredobjectThe request after the cancellation.
record.idintegerLeave request id.
record.employee_idintegerId of the employee taking the leave.
record.leave_policy_idintegerLeave policy id.
record.start_datestring (date)First day of leave.
record.end_datestring (date)Last day of leave.
record.balancestringWorking days the request charges to the leave balance, as a decimal string ("3.0"). Weekends, days off and public holidays are not counted.
record.reasonstringThe reason given.
record.statusstringRequest status: pending (waiting for a decision), approved, rejected, cancelled, or revoked (an approval was taken back).
Allowed values: pending, approved, rejected, cancelled, revoked
record.created_atstringWhen it was submitted, in UTC (2026-03-02 06:00:00 UTC).
record.notestringThe cancellation note you sent.

Errors

HTTPCodeMeaningHow to fix
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_failedThe leave has started, the request is already closed or under cancellation review, or an approved leave was cancelled without a note. error says which.Send a note for an approved leave; otherwise there is nothing left to cancel.
422employee_requiredThe token's owner is a company user with no employee record, so they have no leave of their own.Ask HR to link your user to your employee record, or use a token of a user who has one.
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 →