# GET /api/v1/ap-approval/analytics

> Approval queue analytics

- **Tag:** ap-approval
- **Operation ID:** `get_analytics_api_v1_ap_approval_analytics_get`

## Description

Return queue health stats: pending counts by tier, average age, and oldest pending item.

## Authentication

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

## Responses

### 200 — Successful Response

Schema: `AnalyticsResponse`

- `pending_count` (integer · required) — Total suspended approval executions.
- `pending_by_tier` (object) — Suspended count per tier (ops, advisor, owner).
- `avg_pending_age_hours` (number) — Average age of pending items in hours. Null when queue is empty.
- `oldest_pending_hours` (number) — Age of the oldest pending item in hours. Null when queue is empty.
- `workflow_enabled` (boolean · required) — Whether an AP approval workflow is provisioned for this business.

### 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 GET 'https://api.ondayzero.com/api/v1/ap-approval/analytics' \
  -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/ap-approval/analytics', {
  method: 'GET',
  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.get("https://api.ondayzero.com/api/v1/ap-approval/analytics", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/ap-approval/get-analytics
- OpenAPI slice: https://www.ondayzero.com/docs/reference/ap-approval/get-analytics/openapi.json
- Other endpoints in **ap-approval**: https://www.ondayzero.com/docs/reference/ap-approval
