QHR Developers

Preview the salary deductions of a return

POST/custodies/{id}/return_preview
Read token is enoughAssign, transfer, return and settle custody custody/manage_custodyRequires feature custodyNot available in Claudecustodies.return_preview

Works out, without saving anything, the salary-deduction schedule that custodies.return would create for a damaged or lost asset the employee pays for: how many monthly installments, the regular and last amounts, the first month, every row, and — with labor_law_cap — the monthly cap of five days' wage and the wage it comes from. Deductions start with the payroll of the return month.

When to use: before returning an asset at the employee's cost, to show them what will be deducted. It is a POST only because it takes the return's details; it saves nothing, so a read token may call it.

Prerequisites: the custody id from custodies.list (it must be held). Needs "Manage custody".

Side effects: none — nothing is saved, no one is notified.

Not offered to Claude: the answer carries the employee's monthly wage (monthly_wage), which the custody permission alone should not bring into a chat.

Not available in Claude yet.

Before you call this

You will need ids that come from these operations:

Parameters

NameInTypeDescriptionExample
idRequiredpathintegerCustody id, from custodies.list.311
Accept-LanguageheaderstringLanguage of messages and translated labels. English when omitted.
Allowed values: ar, en
ar

Request body

application/json

FieldTypeDescription
returned_onRequiredstring (date)Return date; not in the future, not before held_since.
conditionRequiredstringdamaged or lost.
Allowed values: intact, damaged, lost
compensation_amountstringCost to recover, at most the value. For lost, the full value when omitted.
borne_byRequiredstringemployee (a schedule exists only then).
Allowed values: company, employee
installments_countintegerNumber of months, 1 to 120. Ignored with labor_law_cap.
labor_law_capbooleanLet QHR set the months so no month takes more than five days' wage (needs an active salary).

Response

200 The schedule the return would create.

FieldTypeDescription
countintegerNumber of monthly installments.
per_installmentstringRegular installment.
last_installmentstringLast installment (absorbs the rounding).
monthly_capstringFive days' wage, with labor_law_cap; else null.
monthly_wagestringBasic salary plus allowances the cap is based on; else null.
first_due_onstring (date)Month of the first deduction.
schedulearray<object>Every installment.
schedule[].sequenceintegerInstallment number.
schedule[].due_onstring (date)Payroll month.
schedule[].amountstringAmount.
currencystringCurrency (the holder's pay currency).

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.
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.
422not_heldThe asset is no longer held by an employee (returned or being deducted).Check its status with custodies.show.
422date_in_futureThe date is after today in the company time zone.Send today or an earlier date.
422date_before_held_sinceThe date is before the current holder received the asset.Send a date on or after held_since.
422condition_requiredcondition is missing or not intact, damaged or lost.Send one of the three.
422not_employee_paidOnly a damaged or lost asset the employee pays for has a schedule.Send condition damaged or lost and borne_by: employee.
422amount_requiredA damaged asset needs a compensation amount above zero.Send compensation_amount.
422amount_exceeds_valueThe compensation is more than the custody value.Send at most the value shown by custodies.show.
422borne_by_requiredborne_by is missing or not company / employee.Say who pays.
422employee_has_packageThe employee is leaving or has a termination package, so the cost cannot be recovered in installments.Return it at the company cost, or let the termination package recover it.
422installments_requiredNo number of installments was given.Send installments_count (1 or more), or labor_law_cap: true.
422installments_count_invalidMore than 120 installments, or under 0.01 each.Choose fewer months.
422no_active_salaryThe labour-law cap needs the employee active salary, above zero.Set the salary, or send installments_count instead of labor_law_cap.
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 →