Settle a loan the employee paid back
/hr_loans/{id}/settleloan/settleRequires feature loanNot available in Claudehr_loans.settleRecords that an employee paid one loan back outside payroll (cash or transfer). A direct loan is settled for its whole amount; a payroll loan for what its installments have not collected yet, and its remaining installments are cancelled so nothing more is deducted from pay. Without accounting approval it is final at once: the loan becomes settled and a received payment is recorded on repaid_on (today by default, never in the future). In a company connected to Qoyod the loan becomes pending_settlement and nothing is recorded until an accountant approves; the answer is then 202 instead of 200.
When to use: when an employee repays a loan early or on its due date. For several loans at once use hr_loans.settle_batch.
Prerequisites: the loan id from hr_loans.for_employee or hr_loans.list (can_settle: true); it must be approved or repaying with money outstanding. The token's owner must be an employee.
Side effects: records a received payment, cancels remaining installments, and sends the repayment (loan.repaid) to Qoyod accounting when connected. Recorded in the audit log. Cannot be undone, so it is not offered to Claude.
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 | Loan id, from hr_loans.list. | 418 |
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 |
|---|---|---|
loan | object | The settlement. |
loan.repaid_on | string (date) | Date the employee repaid; today when omitted. Not in the future, not before the payout. |
Response
200 Settled: the loan is `settled` and the repayment recorded.
| Field | Type | Description |
|---|---|---|
record | object | Everything HR needs to decide a loan. |
record.id | integer | Loan id. |
record.reference | string | Loan reference, e.g. LON-0042. |
record.status | string | Status: pending (waiting for HR), pending_accounting (HR approved, an accountant in Qoyod is deciding), approved (lent, nothing repaid yet), repaying (installments being collected), pending_settlement (a settlement waits for the accountant), settled (paid back), rejected or cancelled.Allowed values: pending, pending_accounting, approved, repaying, pending_settlement, settled, rejected, cancelled |
record.channel | string | How the money moves, chosen by HR at approval: payroll (paid out on a payslip and repaid in monthly installments deducted from pay) or direct (paid out and repaid in one payment outside payroll). Null until approved.Allowed values: payroll, direct, null |
record.installments_count | integer | Number of installments (payroll loans). |
record.currency | string | The employee's pay currency, ISO code. |
record.amount | string | Amount lent. Decimal string. |
record.needed_on | string (date) | Date the employee needs the money. |
record.submitted_at | string | When it was requested, ISO 8601 UTC. |
record.description | string | Why the employee needs it. |
record.disbursement_date | string (date) | Payout date. |
record.installments_start_on | string (date) | First installment month. |
record.installments_end_on | string (date) | Last installment month. |
record.repayment | object | Where a direct loan's single repayment stands; null for a payroll loan or one not approved. |
record.repayment.due_on | string (date) | Repayment due date. |
record.repayment.repaid_on | string (date) | Date it was repaid. |
record.repayment.state | string | not_due, due_soon (within 3 days), overdue, paid_early, paid_on_time or paid_late. |
record.repayment.days | integer | Days to, past or early/late against the due date, by state. |
record.payments | array<object> | Payments behind a direct loan: the payout (paid) and the repayment (received). Always empty for a payroll loan, whose money moves on the payslip. |
record.payments[].id | integer | Payment id. |
record.payments[].reference | string | Payment reference. |
record.payments[].kind | string | paid (to the employee) or received (from them). |
record.payments[].purpose | string | disbursement or repayment. |
record.payments[].date | string (date) | Payment date. |
record.payments[].amount | string | Amount. Decimal string. |
record.payments[].currency | string | The employee's pay currency, ISO code. |
record.decision | object | HR's decision; null while pending. |
record.decision.by | integer | Employee id of who decided. |
record.decision.name | string | Their name. |
record.decision.at | string | When, ISO 8601 UTC. |
record.decision.note | string | Note to the employee. |
record.installments | array<object> | The repayment schedule (payroll loans). |
record.installments[].id | integer | Installment id. |
record.installments[].sequence | integer | Its number, from 1. |
record.installments[].payroll_id | integer | The payroll run collecting it; null until a run claims it. |
record.installments[].due_on | string (date) | Month it is deducted (first day). |
record.installments[].amount | string | Amount. Decimal string. |
record.installments[].currency | string | The employee's pay currency, ISO code. |
record.installments[].status | string | due or paid.Allowed values: due, paid |
record.accounting_mode | string | approval when the company is connected to Qoyod and an accountant approves loans, else legacy (HR's decision is final). |
record.accounting | object | What Qoyod accounting says about the loan (its settlement while one is in play, else its payout). Every field is null when the company is not connected. |
record.accounting.gate | string | loan when an accountant must approve this loan, else none. |
record.accounting.state | string | Delivery state: queued, sending, pending_approval, posted, declined, failed… |
record.accounting.event_id | string | Accounting event id. |
record.accounting.reason_code | string | Why it was declined or held. |
record.accounting.reason | string | The reason in words. |
record.accounting.decided_at | string | When the accountant decided. |
record.accounting.decided_by | string | The accountant (email Qoyod sent). |
record.accounting.resubmit_allowed | boolean | Whether a declined loan may be approved again. |
record.accounting.journal_entry | string | Qoyod journal entry number once posted. |
record.existing_commitments | array<object> | Installments the employee already owes, per month, for the next 2 years. |
record.existing_commitments[].month | string | YYYY-MM. |
record.existing_commitments[].amount | string | Total due. Decimal string. |
record.can_approve | boolean | True when the token's owner may approve it now. |
record.can_reject | boolean | True when the token's owner may reject it now. |
record.can_settle | boolean | True when the token's owner may settle it now. |
record.employee | object | The borrower. |
record.employee.id | integer | Employee id. |
record.employee.employee_no | string | Employee number. |
record.employee.name | string | Name. |
record.employee.email | string | Work email. |
record.employee.job_title | string | Job title. |
record.employee.department | string | Department. |
record.employee.join_date | string (date) | Joining date. |
record.submitted_by | object | Who asked on the employee's behalf. |
record.submitted_by.id | integer | Employee id. |
record.submitted_by.full_name | string | Full name. |
record.salary | object | The active salary and monthly gross and net, to judge affordability; null without an active salary. |
record.salary.id | integer | Salary id. |
record.salary.status | string | Salary status. |
record.salary.pay_frequency | string | Pay frequency. |
record.salary.currency | string | The employee's pay currency, ISO code. |
record.salary.basic_salary_amount | string | Basic salary. Decimal string. |
record.salary.benefits | array<object> | Allowances. |
record.salary.salary_deductions | array<object> | Fixed deductions. |
record.salary.monthly_gross | string | Monthly gross pay. Decimal string. |
record.salary.monthly_net | string | Monthly net pay; no month's installments may exceed it. Decimal string. |
record.other_loans | array<object> | The employee's other loans: reference, status, amounts, schedule and what is outstanding. |
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_settleable | The loan is not approved or repaying. loan_id and reference name the loan. | Settle only loans with can_settle: true in hr_loans.for_employee. |
| 422 | already_pending_settlement | A settlement of the loan already waits for the accountant. loan_id and reference name the loan. | Wait for the accountant's decision in Qoyod. |
| 422 | nothing_outstanding | Nothing is left to repay on the loan. loan_id and reference name the loan. | Leave that loan out. |
| 422 | payout_not_delivered | A payroll loan whose payout has not reached the employee yet. loan_id and reference name the loan. | Pay the payroll run that carries the payout first, or cancel the loan. |
| 422 | installment_in_flight | An installment sits on a payroll run that has not been paid (named in error). loan_id and reference name the loan. | Pay or revert that payroll run first. |
| 422 | repaid_before_disbursement | repaid_on is before the loan was paid out. loan_id and reference name the loan. | Send a repaid_on on or after the payout date. |
| 422 | repaid_in_future | repaid_on is after today. loan_id and reference name the loan. | Record the repayment once the money has arrived. |
| 422 | repaid_on_unreadable | repaid_on is not a date. | Send repaid_on as YYYY-MM-DD. |
| 422 | employee_required | The token's owner has no employee record, and a settlement is recorded in the name of 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