# Analytics

## What it shows

For a range of whole days, a project's calls, connected and billed minutes, what
it was charged, how calls ended, how fast the agent answered, and its chats and
replies: in total, per day, per agent and per call list. The console's
Analytics page shows them with a chart, and the same numbers download as a CSV.

## Reading it from your server

`GET /v2/analytics` and `GET /v2/analytics.csv` take a project key with
`voice:read` (the same key that reads calls and chats). The console uses
`GET /console/v2/projects/{project_id}/analytics` and `.../analytics.csv`.

| Parameter | Meaning |
| --- | --- |
| `from`, `to` | The first and last day, inclusive (`YYYY-MM-DD`), at most 92 days, `to` today at the latest |
| `timezone` | Whose days: a place name such as `Asia/Kolkata` or `America/New_York`, or `UTC` (the default). The console sends your browser's |
| `agent_id` | Only this agent's calls and chats (another project's agent is `404`) |
| `call_list_id` | Only this call list's calls (chats have no list, so their figures are 0) |

```bash
curl -H "X-Api-Key: $PROJECT_KEY" \
  "$API_BASE/v2/analytics?from=2026-11-01&to=2026-11-14&timezone=Asia/Kolkata"
```

## What each number means

- **Days** are whole days in `timezone`. A call belongs to the day it was
  created, a chat message to the day it was written, a conversation to the day
  it started. A call that ran across midnight may sit one day apart from your
  statement, which dates the charge when the call settled.
- **Billed minutes** are whole minutes rounded up per call, the way calls are
  billed. **Charges** are what this account was charged for connected minutes
  and sent chat replies, one entry per currency, as integer strings in units of
  1/`money_scale`. Refused and unsent replies are never charged.
- **Speed**: for each part (`reply_ms`: the caller's words understood to the
  reply's first sound; `llm_first_token_ms`; `tts_first_audio_ms`;
  `greeting_ms`), `p50` is the typical call's own typical time and `p95`
  the slow calls' own slow time, in milliseconds, each call counting once.
  There is no speech-to-text figure: most providers do not report when the
  caller stopped speaking, so it is not measured.
- **How calls ended** is a code per call (`agent_ended` when the agent hung
  up, never the agent's own words), the 20 most common, then `other`.
- **Chats** count conversations started, messages received and replies sent,
  refused or unsure. Chat figures are kept after the messages themselves are
  deleted; days before `chats_complete_from` may miss chats deleted before
  that.

## The CSV

One row per day and agent with any activity, with the columns `day`,
`timezone`, `agent_id`, `agent_name`, the counts, `call_cost_usd`,
`reply_cost_usd`, `call_cost_inr`, `reply_cost_inr` (exact amounts, empty
when the currency was not used), `measured_calls` and each speed part's p50
and p95. At most 10,000 rows: choose fewer days or one agent for more.

## When it says no

| Status | Code | Meaning |
| --- | --- | --- |
| `422` | `range_invalid` | Not whole days, more than 92, or after today in that zone |
| `422` | `timezone_invalid` | Not a place name |
| `404` | `agent_not_found` | No such agent in this project |
| `422` | `too_many_rows` | The file would have more than 10,000 rows |
| `503` | `busy` | Too much to count at once; try a shorter range after `Retry-After` |

## Alerts

An alert watches one figure of a project and tells you when it reaches a
threshold, and again when it is back under it: by email to your account's own
address, by a webhook event to the project's endpoints, or both. Each alert is
checked every 5 minutes over a window you choose. A project can have 10.

| Kind | Threshold | What is measured over the window |
| --- | --- | --- |
| `call_failure_rate` | a percent, 1 to 100 | Of the calls that ended in the window, those that failed: never connected for a reason other than the person's answer (no answer, busy, rejected, cancelled, voicemail), or broken by the voice pipeline or a provider |
| `latency_p95` | milliseconds, 100 to 120,000, on one `stage` | The 95th percentile of the calls' own `p95` on that speed part (`reply_ms` by default, `llm_first_token_ms`, `tts_first_audio_ms` or `greeting_ms`), as above |
| `webhook_failures` | a count, 1 to 10,000 | Deliveries to the project's endpoints that failed or are retrying (never the alert events themselves) |

An alert triggers at or above its threshold. `window_minutes` is 15, 60, 360
or 1440. `min_calls` (default 10) is the fewest calls (measured calls for
latency) a window needs before it is judged at all. `cooldown_minutes` (15 to
1440, default 60) is the least time between two notices that an alert
triggered: a figure that flaps tells you once, its "back under" notice is sent
only when you were told it triggered, and a figure that went over again inside the
quiet time and stays over is told once the quiet time has passed. A call counts in
the window it ended in. A project gets at most 10 triggered
notices a day (UTC).

`GET`, `POST /v2/projects/{project_id}/alerts` and `GET`, `PATCH`,
`DELETE .../alerts/{alert_id}` take a project key: `webhook:read` to read,
`webhook:write` to change. The console uses
`/console/v2/projects/{project_id}/alerts`. A change sends only the fields it
changes; an alert's kind never changes.

```bash
curl -X POST -H "X-Api-Key: $PROJECT_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Calls failing","kind":"call_failure_rate","threshold":20,"window_minutes":60,"notify_webhook":true}' \
  "$API_BASE/v2/projects/$PROJECT_ID/alerts"
```

Each alert carries its `state` (`ok` or `firing`) since `state_since`, and
the last check's `last_value` in its `unit` (`percent`, `ms` or `count`)
with `last_sample`, the calls or deliveries it counted (`last_value` is null
when there were fewer than `min_calls`). Turning a triggered alert off returns
it to `ok` without a notice.

The webhook events are `alert.triggered` and `alert.resolved`, sent to
endpoints subscribed to them, to `alert.*` or to `*` (never `call.*`). Their
`data` carries `alertId`, `projectId`, `name`, `kind`, `stage`,
`state`, `threshold`, `windowMinutes`, `value`, `unit`, `sample` and `at`.

| Status | Code | Meaning |
| --- | --- | --- |
| `404` | `alert_not_found` | No such alert in this project |
| `409` | `too_many_alerts` | The project already has 10 alerts |
| `409` | `switched_off` | Alerts are not switched on yet |
| `422` | `threshold_invalid`, `window_invalid`, `stage_invalid`, `min_calls_invalid`, `cooldown_invalid`, `name_invalid`, `kind_invalid`, `no_destination` | The field it names is not valid |

---

Source: https://developers.dvaarik.com/docs/analytics · every page as one file: https://developers.dvaarik.com/docs.md
