Save an end-of-service package as a draft
/termination_packagestime_off/manage_offboardingRequires feature time_offNot available in Claudetermination_packages.createCalculates an employee's end of service — as termination_packages.preview does — and saves it as a draft with the calculation frozen on it and a reference (EOS-0041). HR may pay a different total than the one calculated by sending compensation_total with an override_reason of at least 20 characters; the difference is kept and shown.
A draft changes nothing: the employee stays active and on payroll, loans and leave are untouched and nothing goes to accounting. All of that happens on termination_packages.confirm.
When to use: once the exit is decided and the figures look right in the preview. An employee can have one package at a time (cancel the old one first).
Prerequisites: employee_id from termination_packages.employee_options, reason_id from termination_reasons.list. The token's owner must be an employee (they are recorded as the creator). The payment date cannot be in the past or before the last working day.
Side effects: a draft package; recorded in the audit log. Not offered to Claude, because it decides what a leaving employee is paid.
Not available in Claude yet.
Before you call this
You will need ids that come from these operations:
Parameters
| Name | In | Type | Description | Example |
|---|---|---|---|---|
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_idRequired | integer | The leaving employee, from termination_packages.employee_options. |
reason_idRequired | integer | Reason, from termination_reasons.list. |
last_working_dayRequired | string (date) | Last working day. |
payment_dateRequired | string (date) | Pay date: today or later, not before the last working day. |
include_last_payroll | boolean | true pays the final partial month in the package (the employee is kept off that payroll run). |
compensation_total | string | Total to pay instead of the calculated one, decimal string. |
override_reason | string | Why the total differs, 20 characters at least. |
Response
201 The draft package.
| Field | Type | Description |
|---|---|---|
record | object | A termination package in full: the frozen calculation, the money, what happened on approval and what may be done next. |
record.id | integer | Package id. |
record.reference | string | Reference, e.g. EOS-0041. |
record.status | string | draft (saved calculation, nothing happened yet), pending_accounting (confirmed, waiting for the accountant in Qoyod), declined (refused by accounting, editable again), paid (approved and the payout recorded) or cancelled.Allowed values: draft, pending_accounting, declined, paid, cancelled |
record.status_label_en | string | Status in English. |
record.status_label_ar | string | Status in Arabic. |
record.include_last_payroll | boolean | True when the final partial month is paid in the package (and the employee is kept off the payroll run for it); false when payroll pays it. |
record.employee | object | The leaving employee. |
record.employee.id | integer | Employee id. |
record.employee.employee_no | string | Employee number. |
record.employee.name_en | string | Name in English. |
record.employee.name_ar | string | Name in Arabic. |
record.employee.department | string | Department. |
record.employee.employment_status | string | Employment status key (active, notice_period, inactive). |
record.last_working_day | string (date) | Last working day. |
record.payment_date | string (date) | Date the package is paid. |
record.compensation_total | string | What the employee is owed (HR's figure when overridden). |
record.offsets_total | string | Loans, deductions and custody taken off. |
record.net_payout | string | What is paid: compensation minus offsets. |
record.currency | string | Currency, ISO code. |
record.has_override | boolean | True when HR entered a total different from the calculated one. |
record.payment_status | string | Whether the payout is recorded. |
record.accounting | object | mode (legacy, or approval when an accountant must approve in Qoyod) and gate. |
record.created_at | string | When it was created, UTC ISO 8601. |
record.reason | object | A reason an employment can end, as the Ministry of Human Resources lists it. |
record.reason.id | integer | Ministry reason id (there is no 8 or 10). |
record.reason.code | string | Stable key, e.g. resignation, contract_expiry, article_80. |
record.reason.name_en | string | Name in English. |
record.reason.name_ar | string | Name in Arabic. |
record.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 |
record.computed_compensation_total | string | What QHR calculated. |
record.override | object | When overridden: computed, entered, variance, reason. |
record.payment | object | The recorded payout: id, reference, kind, purpose, date, amount. |
record.breakdown | object | The calculation frozen when saved: service (tenure), wage_base, gratuity (award and tier), leave_encashment, final_salary, bonuses, deductions, loans, custody, totals. |
record.custody | array<object> | Custody whose value is deducted from the package. |
record.held_custody | array<object> | Assets still held, to be acknowledged at confirm. |
record.calculated_at | string | When the figures were calculated. |
record.confirmed_at | string | When it was confirmed. |
record.approved_at | string | When it became final. |
record.paid_at | string | When the payout was recorded. |
record.cancelled_at | string | When it was cancelled. |
record.created_by | object | Who created it. |
record.confirmed_by | object | Who confirmed it. |
record.stale | boolean | True when the employee's data changed since the calculation; recalculate before confirming. |
record.stale_reasons | array<object> | What changed. |
record.blockers | array<object> | What prevents confirming (code, message). |
record.decisions_outstanding | integer | Accounting decisions still awaited. |
record.loan_settlements | array<object> | The loans this package settles. |
record.effects | object | After confirmation: new employment status, offboarding record, cancelled leave, settled loans, claimed bonuses and deductions, custody, and the payment created. |
record.actions | object | What may be done now: can_edit, can_recalculate, can_confirm, can_cancel. |
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. |
| 422 | not_found | employee_id names no employee. | Take the id from termination_packages.employee_options. |
| 422 | package_already_exists | The employee already has a package that is not cancelled; id, reference and status name it. | Open that package (termination_packages.show), or cancel it first. |
| 422 | employee_not_active | The employee is no longer active (already serving notice or gone). | Nothing to do here; a package is only for an active employee. |
| 422 | payment_date_required | payment_date is missing or not a date. | Send the pay date as YYYY-MM-DD. |
| 422 | payment_date_in_past | The payment date is before today (company time zone). | Use today or a later date. |
| 422 | payment_date_before_last_working_day | The payment date is before the last working day. | Pay on or after the last working day. |
| 422 | override_reason_required | compensation_total differs from the calculated total and no override_reason was sent. | Explain the difference in override_reason, or drop compensation_total. |
| 422 | override_reason_too_short | override_reason is shorter than 20 characters. | Write a real explanation, 20 characters at least. |
| 422 | compensation_total_negative | compensation_total is negative. | Send zero or more. |
| 422 | offsets_exceed_compensation | Loans, deductions and custody owed exceed what the employee is owed; the message gives the shortfall. | Settle part of the loans or custody first, or raise the total. |
| 422 | loan_not_settleable | One of the employee's loans cannot be settled from the package; reference names it. | Resolve that loan first (hr_loans.show). |
| 422 | custody_installment_in_flight | A custody installment is on a payroll run that is not finished; reference names it. | Finish or revert that payroll run first. |
| 422 | payable_not_positive | With accounting approval on, what remains after deductions and custody would be zero or less, which Qoyod refuses. | Override the total with a reason, or settle the custody first. |
| 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. |
| 422 | employee_required | The token's owner has no employee record in this company; every change to a package is stamped with the employee who made it. | Use a token created by a person who is an employee here. |
entitlement_blocked · 429 rate_limited · 500 internal_error