# POST /api/v1/customers/analyze-payment-behavior

> AI payment behavior analysis

- **Tag:** customers
- **Operation ID:** `analyze_payment_behavior_api_v1_customers_analyze_payment_behavior_post`

## Description

Get AI-powered customer payment behavior analysis.

## Authentication

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

## Responses

### 201 — Successful Response

Schema: `AnalyzePaymentBehaviorResponse`

- `items` (array · PaymentBehaviorItem) → `PaymentBehaviorItem`
  - `customer_id` (string · required) — Customer ID
  - `customer_name` (string · required) — Customer name
  - `behavior` (string · required) — early, on_time, late, or delinquent
  - `avg_days_to_pay` (number · required) — Average days to pay
  - `predicted_next_payment` (string) — Predicted next payment date
  - `risk_score` (number · required) — Risk score 0-1
  - `recommendation` (string · required) — Recommended action

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 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/customers/analyze-payment-behavior' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/customers/analyze-payment-behavior', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
  },
});
const data = await response.json();
```

### Python

```python
import httpx

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

response = httpx.post("https://api.ondayzero.com/api/v1/customers/analyze-payment-behavior", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/customers/analyze-payment-behavior
- OpenAPI slice: https://www.ondayzero.com/docs/reference/customers/analyze-payment-behavior/openapi.json
- Other endpoints in **customers**: https://www.ondayzero.com/docs/reference/customers
