Take an asset back from an employee
/custodies/{id}/returncustody/manage_custodyRequires feature custodyNot available in Claudecustodies.returnRecords that a held asset came back, its condition, and — when damaged or lost — what it cost and who pays (borne_by).
- intact, or damaged/lost at the company's cost: the custody becomes returned and is closed. - Damaged/lost at the employee's cost: the custody becomes deducting and a salary-deduction schedule is created — installments_count months, or with labor_law_cap as many months as needed so that no month takes more than five days' wage (basic + allowances). Payroll deducts the installments from the return month on, each as a line on the payslip.
Preview the schedule first with custodies.return_preview; it runs the same checks.
When to use: when an employee hands an asset back, or it is reported damaged or lost.
Prerequisites: the custody id from custodies.list (status held). An employee-paid return is refused while the employee is leaving or has a termination package (the package recovers the cost instead). Needs "Manage custody", and a token owner linked to an employee record.
Side effects: the custody's status, the schedule and a returned history entry with the PDF and the acting HR employee are saved together; recorded in the audit log. No one is notified. A return is final: there is no operation that edits or undoes it.
Not offered to Claude: it is final, can schedule deductions from someone's salary, and uploads a signed PDF (multipart).
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 |
|---|---|---|---|---|
idRequired | path | integer | Custody id, from custodies.list. | 311 |
Accept-Language | header | string | Language of messages and translated labels. English when omitted. Allowed values: ar, en | ar |
Request body
multipart/form-data
| Field | Type | Description |
|---|---|---|
returned_onRequired | string (date) | Return date; not in the future, not before held_since. |
conditionRequired | string | intact, damaged or lost.Allowed values: intact, damaged, lost |
compensation_amount | string | Damaged or lost only: the cost, at most the value. For lost, the full value when omitted. |
borne_by | string | Damaged or lost only: who pays, company or employee.Allowed values: company, employee |
installments_count | integer | Employee-paid only: number of monthly deductions, 1 to 120. Ignored with labor_law_cap.min 1 · max 120 |
labor_law_cap | boolean | Employee-paid only: let QHR set the months so none takes more than five days' wage. |
documentRequired | file | The signed handover form, a PDF of at most 10 MB. |
Response
200 The custody record after the return.
| Field | Type | Description |
|---|---|---|
recordRequired | object | One custody record in full. |
record.id | integer | Custody id. |
record.reference | string | Custody reference, e.g. CUS-0042. |
record.employee | object | The employee holding the asset. |
record.employee.id | integer | Employee id. |
record.employee.full_name | string | Full name. |
record.employee.employee_no | string | Employee number. |
record.employee.department | object | The holder's department. |
record.employee.department.id | integer | Department id. |
record.employee.department.name | string | Department name. |
record.category | object | Category as it was named when handed over. |
record.category.id | integer | Category id. |
record.category.name | string | Category name. |
record.category.icon | string | Category icon key. |
record.item | object | Item as it was named when handed over. |
record.item.id | integer | Item id. |
record.item.name | string | Item name. |
record.serial | string | Serial number of the unit handed over. |
record.value | string | Value of the asset, 2 decimals. |
record.currency | string | Currency of the money fields (the holder's pay currency). |
record.assigned_on | string (date) | Date it was first handed over. |
record.held_since | string (date) | Date the current holder received it. |
record.status | string | held (with the employee), returned (back with the company), deducting (returned damaged or lost, the employee repaying it from salary) or deducted (fully recovered or settled).Allowed values: held, returned, deducting, deducted |
record.installments_paid | integer | Salary deductions already paid; 0 when none. |
record.installments_count | integer | Number of salary deductions scheduled; null when the employee pays nothing. |
record.returned_on | string (date) | Return date; null while held. |
record.condition | string | Condition at return: intact, damaged or lost; null until returned.Allowed values: intact, damaged, lost, null |
record.compensation_amount | string | Cost of the damage or loss; null for an intact return. |
record.borne_by | string | Who pays that cost: company or employee.Allowed values: company, employee, null |
record.labor_law_cap | boolean | True when the deductions were limited to five days' wage a month (labour law). |
record.amount_repaid | string | Already recovered from salary; null unless the employee pays. |
record.outstanding | string | Still to recover; null unless the employee pays. |
record.settlement | object | How the balance was closed (cash, or a termination package); null until settled. |
record.settlement.amount | string | Amount settled. |
record.settlement.date | string (date) | Settlement date. |
record.settlement.source | string | cash or termination_package. |
record.settlement.reason | string | HR's reason, for a cash settlement. |
record.settlement.termination_package | object | The termination package that settled it. |
record.settlement.termination_package.id | integer | Id. |
record.settlement.termination_package.reference | string | Reference. |
record.installments | array<object> | The salary-deduction schedule, oldest first; empty unless the employee pays. |
record.installments[].id | integer | Installment id. |
record.installments[].sequence | integer | Position in the schedule, from 1. |
record.installments[].due_on | string (date) | First day of the month whose payroll deducts it. |
record.installments[].amount | string | Amount. |
record.installments[].currency | string | Currency. |
record.installments[].status | string | paid once the payslip carrying it was paid, due until then.Allowed values: paid, due |
record.installments[].payroll | object | The payroll run that deducted it. |
record.installments[].payroll.id | integer | Id. |
record.installments[].payroll.reference | string | Reference. |
record.timeline | array<object> | What happened to the asset, newest first. |
record.timeline[].kind | string | assigned, transferred, auto_transferred (moved to HR when a leaver's package was paid), returned, installment_deducted, settled or package_settled. |
record.timeline[].occurred_on | string (date) | Date. |
record.timeline[].actor | object | Who did it; null for a system action. |
record.timeline[].actor.id | integer | Employee id. |
record.timeline[].actor.full_name | string | Full name. |
record.timeline[].from_employee | object | Previous holder, for a transfer. |
record.timeline[].from_employee.id | integer | Employee id. |
record.timeline[].from_employee.full_name | string | Full name. |
record.timeline[].to_employee | object | New holder, for an assignment or transfer. |
record.timeline[].to_employee.id | integer | Employee id. |
record.timeline[].to_employee.full_name | string | Full name. |
record.timeline[].amount | string | Money involved, when any. |
record.timeline[].note | string | Settlement reason. |
record.timeline[].condition | string | Condition, for a return. |
record.timeline[].termination_package | object | Related termination package. |
record.timeline[].termination_package.id | integer | Id. |
record.timeline[].termination_package.reference | string | Reference. |
record.timeline[].payroll | object | Payroll run, for a deduction. |
record.timeline[].payroll.id | integer | Id. |
record.timeline[].payroll.reference | string | Reference. |
record.timeline[].installment | object | Which installment, for a deduction. |
record.timeline[].installment.sequence | integer | Installment number. |
record.timeline[].installment.count | integer | Installments in total. |
record.timeline[].document | object | The signed handover PDF. |
record.timeline[].document.url | string | Temporary download link. |
record.timeline[].document.filename | string | File name. |
record.can_return | boolean | True when the caller may take it back now. |
record.can_transfer | boolean | True when the caller may move it to another employee now. |
record.can_settle | boolean | True when the caller may settle the balance in cash now. |
record.settlement_blocker | object | Why the balance cannot be settled in cash, while deducting: claimed_by_package, nothing_outstanding or installment_in_flight. |
record.settlement_blocker.code | string | Reason code. |
record.settlement_blocker.message | string | Explanation. |
record.accounting_connected | boolean | True when the company is connected to Qoyod accounting (a cash settlement is then booked there by hand). |
record.employee_termination_package | object | The holder's open termination package, which blocks moving the asset. |
record.employee_termination_package.id | integer | Id. |
record.employee_termination_package.reference | string | Reference. |
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 | not_held | The asset is no longer held by an employee (returned or being deducted). | Check its status with custodies.show. |
| 422 | date_in_future | The date is after today in the company time zone. | Send today or an earlier date. |
| 422 | date_before_held_since | The date is before the current holder received the asset. | Send a date on or after held_since. |
| 422 | condition_required | condition is missing or not intact, damaged or lost. | Send one of the three. |
| 422 | document_required | The signed handover form is missing. | Attach it as document, a PDF. |
| 422 | document_invalid | The handover form is not a PDF, or is over 10 MB. | Attach a PDF of at most 10 MB. |
| 422 | amount_required | A damaged asset needs a compensation amount above zero. | Send compensation_amount. |
| 422 | amount_exceeds_value | The compensation is more than the custody value. | Send at most the value shown by custodies.show. |
| 422 | borne_by_required | borne_by is missing or not company / employee. | Say who pays. |
| 422 | employee_has_package | The 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. |
| 422 | installments_required | No number of installments was given. | Send installments_count (1 or more), or labor_law_cap: true. |
| 422 | installments_count_invalid | More than 120 installments, or under 0.01 each. | Choose fewer months. |
| 422 | no_active_salary | The labour-law cap needs the employee active salary, above zero. | Set the salary, or send installments_count instead of labor_law_cap. |
| 422 | employee_required | The token owner is a user with no employee record; the operation records who acted, so it needs one. | Use a token created by a user linked to an employee record. |
entitlement_blocked · 429 rate_limited · 500 internal_error