> ## Documentation Index
> Fetch the complete documentation index at: https://test-docs.upayments.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Customers

> Query customer records and profiles

# Customers API

## List Customers

<ParamField query="page" type="number" default="1">Page number</ParamField>
<ParamField query="perPage" type="number" default="20">Results per page</ParamField>
<ParamField query="search" type="string">Search by name, email, or company</ParamField>
<ParamField query="sort" type="string" default="totalSpent">Sort field: totalSpent, totalTransactions, lastPurchaseAt, createdAt</ParamField>

```bash theme={null}
GET /api/customers?search=john&sort=totalSpent&order=desc
```

## Get Customer

```bash theme={null}
GET /api/customers/:id
```

Returns customer profile with:

* Contact information
* Transaction summary (total spent, count, avg, last purchase)
* Linked subscriptions
* Recent transactions
* Health score and risk indicators

## Customer Health Score

Included in the customer detail response:

```json theme={null}
{
  "healthScore": {
    "score": 78,
    "risk": "low",
    "factors": {
      "paymentSuccessRate": 95.5,
      "tenure": 8,
      "recentActivity": true,
      "averageTransactionValue": 250.00,
      "totalRevenue": 12500.00,
      "transactionCount": 50
    }
  }
}
```
