QHR Developers

Calculate end of service without saving

GET/termination_packages/preview
Read token is enoughManage employee offboarding time_off/manage_offboardingRequires feature time_offAvailable in Claudetermination_packages.preview

Calculates 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

NameInTypeDescriptionExample
employee_idRequiredqueryintegerThe leaving employee, from termination_packages.employee_options.1203
reason_idRequiredqueryintegerReason, from termination_reasons.list.9
last_working_dayRequiredquerystring (date)Last working day.2026-12-31
include_last_payrollquerybooleantrue pays the final partial month in the package instead of through payroll.false
Accept-LanguageheaderstringLanguage of messages and translated labels. English when omitted.
Allowed values: ar, en
ar

Response

200 The calculation.

FieldTypeDescription
employeeobjectThe employee.
contractobjectContract type.
reasonobjectA reason an employment can end, as the Ministry of Human Resources lists it.
reason.idintegerMinistry reason id (there is no 8 or 10).
reason.codestringStable key, e.g. resignation, contract_expiry, article_80.
reason.name_enstringName in English.
reason.name_arstringName in Arabic.
reason.payout_classstringEffect 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
serviceobjectTenure: join_date, years, months, days, and a hint when close to the next award tier.
wage_baseobjectThe monthly wage the award uses and the daily wage.
gratuityobjectThe award: amount and tier.
leave_encashmentobjectUnused leave paid out: days, amount, and policies left out with why.
affected_leave_requestsarray<object>Approved leave after the last day, cancelled on confirm.
final_salaryobjectThe final partial month, when paid in the package.
bonusesarray<object>Pending bonuses added.
deductionsarray<object>Pending deductions taken off.
loansarray<object>Outstanding loans settled from the package.
custodyarray<object>Custody deducted.
held_custodyarray<object>Assets still held.
totalsobjectcompensation, offsets and net_payout.
accountingobjectWhether an accountant must approve.
blockersarray<object>What would stop saving (code, message).

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.
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.
422no_active_salaryThe employee has no active salary, so there is no wage to calculate from.Give the employee an active salary (salaries.create).
422no_join_dateThe employee has no join date, so the length of service is unknown.Set the join date with employees.update (employment_detail.join_date).
422unknown_reasonreason_id is not one of the ministry's reasons.Pick an id from termination_reasons.list.
422last_working_day_requiredlast_working_day is missing or not a date.Send the last working day as YYYY-MM-DD.
422last_working_day_before_join_dateThe last working day is before the employee joined.Correct the last working day, or the join date.
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 →