# POST /api/v1/api-clients

> Create API client

- **Tag:** api-clients
- **Operation ID:** `create_api_client`

## Description

Register a partner API client with its public keys (JWK set). Requires the two-factor step-up; refused for API tokens.

## Authentication

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

## Request body

Schema: `ApiClientCreate`

- `name` (string · required) — Client name
- `description` (string)
- `scopes` (array · string) — What every token issued to this client may do. Same vocabulary as API tokens: `credit`, `credit:read`, `credit:payments`, `read_only`, `api` (full access).
- `allowed_ips` (array · string) — IPv4/IPv6 addresses or CIDR ranges the client may request tokens from and use them from. Omit for any IP.
- `rate_limit_per_minute` (integer) — Requests per minute each issued token may make; omit for the platform default.
- `token_ttl_seconds` (integer) — Lifetime of each access token, in seconds (60-3600).
- `jwks` (object · required) — JWK set (`{"keys": [...]}`) with the public keys the client signs its assertions with: RS256 (RSA >= 2048 bits), ES256 (P-256) or EdDSA (Ed25519). Public members only; every key needs a `kid` when there is more than one.
- `require_mtls` (boolean) — Bind every token to the client certificate presented at the token endpoint (RFC 8705). Only available where the load balancer forwards client certificates (`mtls_available`).
- `mtls_cert_thumbprints` (array · string) — Optional pin list of SHA-256 certificate thumbprints (hex or base64url). Empty: any certificate the load balancer accepted.
- `require_signed_requests` (boolean) — Payment requests must also carry a signature from a signing key.

## Example request

```json
{
  "allowed_ips": [
    "203.0.113.10"
  ],
  "description": "Tie's payment job",
  "jwks": {
    "keys": [
      {
        "alg": "ES256",
        "crv": "P-256",
        "kid": "tie-2026-10",
        "kty": "EC",
        "use": "sig",
        "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
        "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
      }
    ]
  },
  "name": "Tie production",
  "rate_limit_per_minute": 600,
  "require_mtls": false,
  "require_signed_requests": true,
  "scopes": [
    "credit:payments"
  ],
  "token_ttl_seconds": 900
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_ApiClientResponse_`

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

### 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.

### 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.

### 429 — Too Many Requests - Rate limit exceeded; back off and retry

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 POST 'https://api.ondayzero.com/api/v1/api-clients' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "allowed_ips": [
    "203.0.113.10"
  ],
  "description": "Tie'\''s payment job",
  "jwks": {
    "keys": [
      {
        "alg": "ES256",
        "crv": "P-256",
        "kid": "tie-2026-10",
        "kty": "EC",
        "use": "sig",
        "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
        "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
      }
    ]
  },
  "name": "Tie production",
  "rate_limit_per_minute": 600,
  "require_mtls": false,
  "require_signed_requests": true,
  "scopes": [
    "credit:payments"
  ],
  "token_ttl_seconds": 900
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/api-clients', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "allowed_ips": [
    "203.0.113.10"
  ],
  "description": "Tie's payment job",
  "jwks": {
    "keys": [
      {
        "alg": "ES256",
        "crv": "P-256",
        "kid": "tie-2026-10",
        "kty": "EC",
        "use": "sig",
        "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
        "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
      }
    ]
  },
  "name": "Tie production",
  "rate_limit_per_minute": 600,
  "require_mtls": false,
  "require_signed_requests": true,
  "scopes": [
    "credit:payments"
  ],
  "token_ttl_seconds": 900
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'allowed_ips': ['203.0.113.10'],
 'description': "Tie's payment job",
 'jwks': {'keys': [{'alg': 'ES256',
                    'crv': 'P-256',
                    'kid': 'tie-2026-10',
                    'kty': 'EC',
                    'use': 'sig',
                    'x': 'f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU',
                    'y': 'x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0'}]},
 'name': 'Tie production',
 'rate_limit_per_minute': 600,
 'require_mtls': False,
 'require_signed_requests': True,
 'scopes': ['credit:payments'],
 'token_ttl_seconds': 900}

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

## See also

- HTML version: https://www.ondayzero.com/docs/reference/api-clients/create-api-client
- OpenAPI slice: https://www.ondayzero.com/docs/reference/api-clients/create-api-client/openapi.json
- Other endpoints in **api-clients**: https://www.ondayzero.com/docs/reference/api-clients (markdown bundle: https://www.ondayzero.com/docs/reference/api-clients.md, OpenAPI: https://www.ondayzero.com/docs/reference/api-clients/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
