Calculate end of service without saving
/termination_packages/previewtime_off/manage_offboardingRequires feature time_offAvailable in Claudetermination_packages.previewCalculates what an employee would be owed if they left on last_working_day for reason_id, and saves nothing. The answer shows the length of service, the wage the award is based on (basic plus fixed allowances), the award under the Saudi labour law (half a month's wage per year for the first five years, a full month after; resignations scaled by tenure), unused leave paid out, the final salary when include_last_payroll is true, pending bonuses, and what is taken off — loans, deductions and custody — down to the net payout. blockers lists what would stop the package being saved (an active loan that cannot be settled, offsets larger than the award…).
When to use: to answer "how much end-of-service would Ahmed get if he resigned at the end of the year?", or before termination_packages.create.
Prerequisites: employee_id from termination_packages.employee_options, reason_id from termination_reasons.list. The employee needs a join date and an active salary.
Side effects: none — no package, no status change, no leave cancelled.
Before you call this
You will need ids that come from these operations:
Parameters
| Name | In | Type | Description | Example |
|---|---|---|---|---|
employee_idRequired | query | integer | The leaving employee, from termination_packages.employee_options. | 1203 |
reason_idRequired | query | integer | Reason, from termination_reasons.list. | 9 |
last_working_dayRequired | query | string (date) | Last working day. | 2026-12-31 |
include_last_payroll | query | boolean | true pays the final partial month in the package instead of through payroll. | false |
Accept-Language | header | string | Language of messages and translated labels. English when omitted. Allowed values: ar, en | ar |
Response
200 The calculation.
| Field | Type | Description |
|---|---|---|
employee | object | The employee. |
contract | object | Contract type. |
reason | object | A reason an employment can end, as the Ministry of Human Resources lists it. |
reason.id | integer | Ministry reason id (there is no 8 or 10). |
reason.code | string | Stable key, e.g. resignation, contract_expiry, article_80. |
reason.name_en | string | Name in English. |
reason.name_ar | string | Name in Arabic. |
reason.payout_class | string | Effect on the award: full, none (e.g. Article 80) or tiered (resignation: none under 2 years, one third 2–5, two thirds 5–10, full from 10).Allowed values: full, none, tiered |
service | object | Tenure: join_date, years, months, days, and a hint when close to the next award tier. |
wage_base | object | The monthly wage the award uses and the daily wage. |
gratuity | object | The award: amount and tier. |
leave_encashment | object | Unused leave paid out: days, amount, and policies left out with why. |
affected_leave_requests | array<object> | Approved leave after the last day, cancelled on confirm. |
final_salary | object | The final partial month, when paid in the package. |
bonuses | array<object> | Pending bonuses added. |
deductions | array<object> | Pending deductions taken off. |
loans | array<object> | Outstanding loans settled from the package. |
custody | array<object> | Custody deducted. |
held_custody | array<object> | Assets still held. |
totals | object | compensation, offsets and net_payout. |
accounting | object | Whether an accountant must approve. |
blockers | array<object> | What would stop saving (code, message). |
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 | 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 | no_active_salary | The employee has no active salary, so there is no wage to calculate from. | Give the employee an active salary (salaries.create). |
| 422 | no_join_date | The employee has no join date, so the length of service is unknown. | Set the join date with employees.update (employment_detail.join_date). |
| 422 | unknown_reason | reason_id is not one of the ministry's reasons. | Pick an id from termination_reasons.list. |
| 422 | last_working_day_required | last_working_day is missing or not a date. | Send the last working day as YYYY-MM-DD. |
| 422 | last_working_day_before_join_date | The last working day is before the employee joined. | Correct the last working day, or the join date. |
entitlement_blocked · 429 rate_limited · 500 internal_error