# PUT /api/v1/credit/debt-facilities

> Replace a merchant's existing debt facilities

- **Tag:** credit
- **Operation ID:** `put_credit_debt_facilities`

## Description

Name the merchant as on `POST /credit/bank-feeds` (`program_id` and `external_merchant_id`, or `credit_line_id`); DayZero uses its business, creating it the first time, and gives your token read access to it. `facilities` is the whole list: a facility sent again (same `facility_id`) is updated, one left out is removed, and an empty list attests the merchant has no debt. They land on the merchant's debt schedule, which `existing_debt_facilities` and `debt_service_coverage_ratio` read; with none attested the first reads 0 and the second uncapped cover instead of unmeasured. A `daily`, `weekly`, `biweekly` or `semi_monthly` payment counts at its yearly total (252 business days for `daily`).

## Authentication

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

## Request body

Schema: `DebtFacilitiesRequest`

- `program_id` (string) — Your program the merchant is applying under. Required without `credit_line_id`; with it, must be the line's program if sent.
- `external_merchant_id` (string) — Your id for the merchant, as on `POST /credit/bank-feeds` and `POST /credit/lines`. Required without `credit_line_id`.
- `credit_line_id` (string) — The merchant's open line, when there is one.
- `merchant_legal_name` (string) — Names the merchant's DayZero business when this call creates it. Ignored when the business exists.
- `merchant_business_id` (string) — The merchant's existing DayZero business, when your token can reach it. Leave it out and DayZero uses the business the merchant was linked to before, or creates one.
- `facilities` (array · DebtFacilityItem · required) → `DebtFacilityItem` — The merchant's facilities, all of them: one left out of a push is removed. An empty list attests the merchant has none, so `existing_debt_facilities` reads 0 and `debt_service_coverage_ratio` reads as uncapped cover.
  - `facility_id` (string · required) — Your stable id for the facility; a push updates it in place.
  - `lender` (string · required) — Who lent it.
  - `facility_type` (string · required) (one of: term_loan, line_of_credit, mca, revenue_based, sba_loan, equipment_loan, mortgage, credit_card, other) — What it is. `mca` and `revenue_based` are repaid from sales; `credit_card` is a card balance.
  - `current_balance_cents` (integer · required) — What is still owed today, in cents.
  - `original_amount_cents` (integer) — The amount first lent (defaults to the current balance).
  - `payment_amount_cents` (integer) — The scheduled payment per `payment_frequency`, in cents. Without it the facility adds nothing to annual debt service.
  - `payment_frequency` (string) — How often `payment_amount_cents` is paid. `daily` counts 252 business days a year. Required with `payment_amount_cents`.
  - `interest_rate_bps` (integer) — Annual interest rate in basis points (500 = 5.00%).
  - `started_on` (string · date) — When it was drawn (defaults to today).
  - `maturity_on` (string · date) — When it is due to be repaid (defaults to a year after start).

## Responses

### 200 — Successful Response

Schema: `SuccessEnvelope_DebtFacilitiesResponse_`

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

### 400 — Bad Request - Invalid input

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

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

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## Code samples

### cURL

```bash
curl -X PUT 'https://api.ondayzero.com/api/v1/credit/debt-facilities' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "facilities": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/credit/debt-facilities', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "facilities": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'facilities': []}

response = httpx.put("https://api.ondayzero.com/api/v1/credit/debt-facilities", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/credit/put-credit-debt-facilities
- OpenAPI slice: https://www.ondayzero.com/docs/reference/credit/put-credit-debt-facilities/openapi.json
- Other endpoints in **credit**: https://www.ondayzero.com/docs/reference/credit (markdown bundle: https://www.ondayzero.com/docs/reference/credit.md, OpenAPI: https://www.ondayzero.com/docs/reference/credit/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
