QHR Developers

Assign a leave policy to employees

POST/leave_policies/{leave_policy_id}/employees
Needs a read & write tokenAssign policies to employees leave_policy/assignRequires feature leave_policyNot available in Claudeemployee_leave_policies.assign

Gives a leave policy to the employees in employee_ids, or to every active employee who can take it with "all". Each employee is handled on their own: those who already hold a policy of the same leave category, or do not exist, are skipped with a reason, and the rest are assigned.

What happens to the balance: each new holder gets their first grant at once, following the policy's accrual (see leave_policies.create): a pro-rated share of the year counted from their joining date for per_year + full_balance, the rest of the current month for monthly, the full entitlement for one_time_only, nothing for per_event. Accrual then continues on its schedule. Re-assigning someone the policy was removed from restores their previous balance and history instead of granting again; accrual restarts from today.

Prerequisites: leave_policy_id from leave_policies.list; employee ids from employee_leave_policies.eligible.

Side effects: balances created and the assignment written to each employee's statement; recorded in the audit log. Not offered to Claude: it grants paid leave entitlements, possibly to the whole company at once.

Irreversible operation

This operation cannot be undone and can affect the whole company. Double-check the ids before you call it. For safety it is never offered through Claude.

Before you call this

You will need ids that come from these operations:

Parameters

NameInTypeDescriptionExample
leave_policy_idRequiredpathintegerLeave policy id, from leave_policies.list.12
Accept-LanguageheaderstringLanguage of messages and translated labels. English when omitted.
Allowed values: ar, en
ar

Request body

application/json

FieldTypeDescription
employee_idsRequiredanyEmployee ids, or the string "all" for every active employee who holds no policy of this category yet.

Response

201 Who was assigned and who was skipped.

FieldTypeDescription
messagestringConfirmation.
assignedarray<object>Employees now holding the policy.
assigned[].employee_idintegerEmployee id.
assigned[].namestringFull name; null when the employee does not exist.
assigned[].restoredbooleanAssigned items only: true when a previous assignment and its balance were restored.
assigned[].reasonstringSkipped items only: why.
skippedarray<object>Employees not assigned, with the reason.
skipped[].employee_idintegerEmployee id.
skipped[].namestringFull name; null when the employee does not exist.
skipped[].restoredbooleanAssigned items only: true when a previous assignment and its balance were restored.
skipped[].reasonstringSkipped items only: why.

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_failedNo employee was assigned. skipped gives each one's reason (already holds a policy of this category, or not found).Pick employees from employee_leave_policies.eligible.
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 →