# POST /api/v1/counterparty-defaults

> Create a counterparty default

- **Tag:** counterparty-defaults
- **Operation ID:** `create_counterparty_default_api_v1_counterparty_defaults_post`

## Description

Create a new counterparty default.

Provide either ``registry_id`` (preferred — survives renames) or a
raw ``counterparty_name`` string. ``default_ledger_id`` must be a
non-bank ledger.

## Authentication

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

## Request body

Schema: `CounterpartyDefaultCreate`

- `registry_id` (string) — Linked counterparty registry entry. Preferred — survives name normalisation. When provided, ``counterparty_name`` is treated as a display label only.
- `counterparty_name` (string) — Raw counterparty string used when the counterparty is not linked to the registry. Required when ``registry_id`` is absent.
- `default_ledger_id` (string · required) — Ledger to categorize matched transactions to.
- `memo` (string) — Optional memo to stamp on matches.
- `mark_personal` (boolean) — Mark matched transactions as personal expenses.

## Responses

### 201 — Successful Response

Schema: `CounterpartyDefaultResponse`

- `id` (string · required)
- `business_id` (string · required)
- `registry_id` (string · required)
- `counterparty_name` (string · required)
- `default_ledger_id` (string · required)
- `default_ledger_name` (string)
- `memo` (string · required)
- `mark_personal` (boolean · required)
- `created_at` (string · date-time · required)
- `updated_at` (string · date-time · required)

### 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/counterparty-defaults' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "default_ledger_id": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/counterparty-defaults', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "default_ledger_id": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "default_ledger_id": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/counterparty-defaults", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/counterparty-defaults/create-counterparty-default
- OpenAPI slice: https://www.ondayzero.com/docs/reference/counterparty-defaults/create-counterparty-default/openapi.json
- Other endpoints in **counterparty-defaults**: https://www.ondayzero.com/docs/reference/counterparty-defaults
