# Analytics API

Source: https://aicallstudio.com/docs/api/analytics. Authentication, scopes, limits, errors and webhooks: https://aicallstudio.com/docs/api

### Calls by classification

`GET /api/analytics/classification-breakdown` (scope `analytics:read`)

Calls counted by lead classification (hot, warm, cold, unclassified), most common first.

By default the last 30 days; `date_from` and `date_to` (IST calendar days) pick a range instead.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `days` | integer, 1 to 365, in the query | The last this many days, 1 to 365. date_from overrides it. Default: 30. |
| `date_from` | string (date), or null, in the query | IST calendar day, YYYY-MM-DD. Beats `days`. |
| `date_to` | string (date), or null, in the query | IST calendar day, inclusive (default today). |
| `agent_id` | string (uuid), or null, in the query | Only calls this AI agent answered. |
| `team_id` | string (uuid), or null, in the query | Only calls this AI team answered. |
| `mode` | one of: ai, power, or null, in the query | Campaign mode: power or ai. |
| `desk_id` | string (uuid), or null, in the query | Calls attributed to this desk: to or from one of its numbers, or handed over through an 'A desk' step and taken by someone on it. |
| `staff_user` | string (uuid), or null, in the query | One team member's calls, as Call Logs' Person filter counts them: hand-overs they answered, calls they dialled from the Workspace, and calls passed or put through to them. |
| `campaign_id` | string (uuid), or null, in the query | Calls this campaign placed. |
| `direction` | one of: inbound, outbound, or null, in the query | Calls in or out. A web call is inbound, as on Call Logs. |

**Answer (200): a list, each item with these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `classification` (required) | string | hot, warm, cold, or unclassified. |
| `count` (required) | integer | — |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl "https://aicallstudio.com/api/analytics/classification-breakdown?days=30" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN"
```

### Calls by outcome

`GET /api/analytics/disposition-breakdown` (scope `analytics:read`)

Calls counted by outcome, most common first, each with its name in your workspace.

By default the last 30 days; `date_from` and `date_to` (IST calendar days) pick a range instead.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `days` | integer, 1 to 365, in the query | The last this many days, 1 to 365. date_from overrides it. Default: 30. |
| `date_from` | string (date), or null, in the query | IST calendar day, YYYY-MM-DD. Beats `days`. |
| `date_to` | string (date), or null, in the query | IST calendar day, inclusive (default today). |
| `agent_id` | string (uuid), or null, in the query | Only calls this AI agent answered. |
| `team_id` | string (uuid), or null, in the query | Only calls this AI team answered. |
| `mode` | one of: ai, power, or null, in the query | Campaign mode: power or ai. |
| `desk_id` | string (uuid), or null, in the query | Calls attributed to this desk: to or from one of its numbers, or handed over through an 'A desk' step and taken by someone on it. |
| `staff_user` | string (uuid), or null, in the query | One team member's calls, as Call Logs' Person filter counts them: hand-overs they answered, calls they dialled from the Workspace, and calls passed or put through to them. |
| `campaign_id` | string (uuid), or null, in the query | Calls this campaign placed. |
| `direction` | one of: inbound, outbound, or null, in the query | Calls in or out. A web call is inbound, as on Call Logs. |

**Answer (200): a list, each item with these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `disposition` (required) | string | The outcome key, or unknown for calls with none. |
| `label` (required) | string | The outcome's name in your workspace. |
| `group` | string, or null | The group the outcome belongs to. |
| `count` (required) | integer | — |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl "https://aicallstudio.com/api/analytics/disposition-breakdown?days=30" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN"
```

### Call summary

`GET /api/analytics/summary` (scope `analytics:read`)

Call totals for the last `days` days: calls, connected calls, minutes, duration and score.

A connected call is one someone picked up; an answering machine does not count.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `days` | integer, 1 to 365, in the query | The period: the last this many days, 1 to 365. Default: 30. |
| `agent_id` | string (uuid), or null, in the query | Only calls this AI agent answered. |
| `team_id` | string (uuid), or null, in the query | Only calls this AI team answered. |
| `mode` | one of: ai, power, or null, in the query | Campaign mode: power or ai. |
| `campaign_only` | boolean, in the query | Count only calls a campaign placed. Default: false. |

**Answer (200): these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `period_days` (required) | integer | The period counted: the last `days` days. |
| `total_calls` (required) | integer | — |
| `completed_calls` (required) | integer | Calls someone picked up. The same number as `connected_calls`. |
| `connected_calls` (required) | integer | Calls someone picked up. An answering machine does not count. |
| `completion_rate` (required) | number | Connected calls as a percentage of all calls, to one decimal place. |
| `total_billed_minutes` | number, or null | Minutes billed for these calls. |
| `avg_duration_sec` (required) | number | — |
| `avg_qa_score` | number, or null | Average lead score of the scored calls; null when none was scored. |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl "https://aicallstudio.com/api/analytics/summary?days=30" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN"
```
