> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cr3dentials.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Repayments

> Report each repayment deducted from a borrower's deposits, and each repayment to the credit line.

Send one event per repayment deducted from a borrower's income deposit, and one per repayment you make to the credit line. Both go to `POST /v1/events`, the same endpoint that takes [money-step confirmations](https://docs.cr3dentials.xyz/lending/money-steps.md#confirming-a-step).

## Repaying a loan

```mermaid actions={false} theme={null}
sequenceDiagram
    autonumber
    participant P as Your platform
    participant C as Cr3dentials
    C-->>P: Loan view with deduction v1
    P->>P: Deduct from a deposit
    P->>C: POST /v1/events deposit.settled (instruction_version 1)
    C-->>P: 202, loan view with deduction v2
    P->>P: Deduct the rest
    P->>C: POST /v1/events deposit.settled (instruction_version 2)
    C-->>P: 202, loan repaid
    P->>C: GET /v1/loans/{loan_id}, 1 minute later
    C-->>P: instructions [release_hold]
    P->>C: POST /v1/events hold.released
    C-->>P: 202
```

When a deduction repays the loan, `release_hold` follows within seconds, and `refund` too when more was deducted than owed. Neither is in that event's answer, so read the loan a minute later.

## Events

Use the `event_id` as the `Idempotency-Key`. A repeated `event_id`, `ledger_operation_id` or `repayment_id` answers 202 and changes nothing.

```json deposit.settled theme={null}
{
  "event_id": "evt_1",
  "type": "deposit.settled",
  "created_at": "2026-11-25T14:00:05Z",
  "data": {
    "loan_id": "c4d5e6f7-0a1b-4c2d-8e3f-a4b5c6d7e8f9",
    "partner_account_id": "acc_83920",
    "instruction_version": 1,
    "deposit_id": "dep_1",
    "ledger_operation_id": "op_1",
    "deposit_amount_cents": 140000,
    "deducted_cents": 10500,
    "settled_at": "2026-11-25T14:00:00Z",
    "transfer_type": "bank_transfer",
    "from_outside_institution": true,
    "into_own_account": true,
    "payer_name": "ACME PAYROLL SAS",
    "beneficiary_name": "MARIA PEREZ GOMEZ"
  }
}
```

```json tradevu.repayment theme={null}
{
  "event_id": "evt_2",
  "type": "tradevu.repayment",
  "created_at": "2026-11-26T10:00:00Z",
  "data": {
    "loan_id": "c4d5e6f7-0a1b-4c2d-8e3f-a4b5c6d7e8f9",
    "partner_account_id": "acc_83920",
    "repayment_id": "rep_1",
    "principal_cents": 10000,
    "repaid_at": "2026-11-26T09:58:00Z"
  }
}
```

### `deposit.settled` rules

**data.deducted\_cents** `integer` *required*

At least 1, and no more than `deposit_amount_cents`.

**data.settled\_at** `string` *required*

No earlier than the payout, and at most 5 minutes ahead of our clock.

**data.instruction\_version** `integer` *required*

The [deduction](https://docs.cr3dentials.xyz/lending/money-steps.md#deductions) version you applied.

### `tradevu.repayment` rules

**data.principal\_cents** `integer` *required*

No more than the principal still owed on that loan's credit line.

## Answers

| Answer | Meaning |
| - | - |
| 202 `{"event_id", "loan"}` | Recorded, or already recorded. `loan` is the loan view with its pending instructions. |
| 400 | A field is invalid, `partner_account_id` doesn't match the loan, or `data` doesn't parse (fixed message, no values echoed) |
| 404 | Unknown loan, or another partner's loan |
| 409 `INVALID_STATE` | The loan isn't paid out, or can't take this event |
| 422 `REPAYMENT_EXCEEDS_LINE` | A credit-line repayment above what is owed |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.