# POST /api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants

> Add a covenant to a debt instrument

- **Tag:** cfo-portal
- **Operation ID:** `cfo_portal_create_debt_covenant_api_v1_businesses__business_id__cfo_portal_debt_schedule_instruments__instrument_id__covenants_post`

## Description

Attach a financial covenant to a loan.

## Authentication

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

## Parameters

- `business_id` (path, string, required)
- `instrument_id` (path, string, required)

## Request body

Schema: `DebtCovenantCreateRequest`

- `metric_name` (string · required)
- `operator` (string · required) — CovenantOperatorEnum: greater_than, less_than, greater_than_or_equal, less_than_or_equal.
- `threshold_value` (string · required)
- `measurement_frequency` (string) — PaymentFrequencyEnum cadence for measurement.
- `description` (string)

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_DebtCovenantResponse_`

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

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

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

### 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/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "metric_name": "string",
  "operator": "string",
  "threshold_value": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "metric_name": "string",
  "operator": "string",
  "threshold_value": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "metric_name": "string",
  "operator": "string",
  "threshold_value": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/businesses/{business_id}/cfo-portal/debt-schedule/instruments/{instrument_id}/covenants", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/cfo-portal/cfo-portal-create-debt-covenant
- OpenAPI slice: https://www.ondayzero.com/docs/reference/cfo-portal/cfo-portal-create-debt-covenant/openapi.json
- Other endpoints in **cfo-portal**: https://www.ondayzero.com/docs/reference/cfo-portal
