# POST /api/v1/loans/{instrument_id}/write-off

> Write off a loan

- **Tag:** loans
- **Operation ID:** `write_off_loan_api_v1_loans__instrument_id__write_off_post`

## Description

Write off all (default) or part of a loan's balance.

**Request Body:**
- `principal_cents`: Principal to write off (optional; omit for the
  full remaining balance).
- `write_off_date`: Effective date (optional, defaults to today).
- `memo`: Optional journal-entry memo.

**Effect:**
- Loans we made post to Bad Debt Expense; debt we owe posts to Debt
  Forgiveness Income.
- A full write-off also clears accrued unpaid interest and marks the
  loan `written_off`.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `instrument_id` (path, string, required)

## Request body

Schema: `LoanWriteOffRequest`

- `write_off_date` (string · date)
- `principal_cents` (integer) — Principal to write off; omit for the full remaining balance.
- `memo` (string)

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_LoanWriteOffResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (LoanWriteOffResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 409 — Conflict - Resource already exists

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/loans/{instrument_id}/write-off' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "write_off_date": "2026-01-01",
  "principal_cents": 0,
  "memo": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/loans/{instrument_id}/write-off', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "write_off_date": "2026-01-01",
  "principal_cents": 0,
  "memo": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "write_off_date": "2026-01-01",
  "principal_cents": 0,
  "memo": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/loans/{instrument_id}/write-off", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/loans/write-off-loan
- OpenAPI slice: https://www.ondayzero.com/docs/reference/loans/write-off-loan/openapi.json
- Other endpoints in **loans**: https://www.ondayzero.com/docs/reference/loans
