# POST /api/v1/counterparty-aliases

> Create or update a counterparty alias

- **Tag:** counterparty-aliases
- **Operation ID:** `create_counterparty_alias_api_v1_counterparty_aliases_post`

## Description

Create a counterparty alias, upserting when one already exists for
the same counterparty.

Provide either ``registry_id`` (preferred — applies to every
transaction linked to that registry entry) or a raw
``counterparty_name`` string for unlinked counterparties.

## Authentication

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

## Request body

Schema: `CounterpartyAliasCreate`

- `registry_id` (string) — Linked counterparty registry entry. Preferred — the alias then applies to every transaction linked to that entry, surviving raw-string variations.
- `counterparty_name` (string) — Raw counterparty string to match (case-insensitive) when the counterparty is not linked to the registry. Required when ``registry_id`` is absent.
- `display_name` (string · required) — Name to display for this counterparty in this business.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_CounterpartyAliasResponse_`

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

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

### JavaScript

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

### Python

```python
import httpx

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

payload = {
  "display_name": "string"
}

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

## See also

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