Assign a leave policy to employees
/leave_policies/{leave_policy_id}/employeesleave_policy/assignRequires feature leave_policyNot available in Claudeemployee_leave_policies.assignGives 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.
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
| Name | In | Type | Description | Example |
|---|---|---|---|---|
leave_policy_idRequired | path | integer | Leave policy id, from leave_policies.list. | 12 |
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 |
|---|---|---|
employee_idsRequired | any | Employee 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.
| Field | Type | Description |
|---|---|---|
message | string | Confirmation. |
assigned | array<object> | Employees now holding the policy. |
assigned[].employee_id | integer | Employee id. |
assigned[].name | string | Full name; null when the employee does not exist. |
assigned[].restored | boolean | Assigned items only: true when a previous assignment and its balance were restored. |
assigned[].reason | string | Skipped items only: why. |
skipped | array<object> | Employees not assigned, with the reason. |
skipped[].employee_id | integer | Employee id. |
skipped[].name | string | Full name; null when the employee does not exist. |
skipped[].restored | boolean | Assigned items only: true when a previous assignment and its balance were restored. |
skipped[].reason | string | Skipped items only: why. |
Errors
| HTTP | Code | Meaning | How to fix |
|---|---|---|---|
| 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 | No 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. |
entitlement_blocked · 429 rate_limited · 500 internal_error