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

# Analytics

> Aggregate call volume, connect rate, duration, cost and latency across your workspace.

Analytics answers the questions a single [session](/concepts/sessions) can't: how many calls ran this week, how many actually connected, what they cost, and how fast the agent responded. It aggregates every call in the workspace — API-fired, campaign and inbound alike — over a date range.

## Endpoints

| Method | Path                        | Scope            |
| ------ | --------------------------- | ---------------- |
| GET    | `/analytics/overview`       | `analytics:read` |
| GET    | `/analytics/overview/trend` | `analytics:read` |

Both accept the same query parameters:

| Param         | Default                  | Notes                                                |
| ------------- | ------------------------ | ---------------------------------------------------- |
| `from` / `to` | Last 7 days ending today | Inclusive UTC days, `YYYY-MM-DD`. Max span 400 days. |
| `agent_id`    | —                        | Restrict to one agent.                               |
| `campaign_id` | —                        | Restrict to one campaign.                            |

## Overview

```bash theme={null}
curl "$LEHAR_BASE_URL/analytics/overview?from=2026-08-01&to=2026-08-11" \
  -H "X-API-KEY: $LEHAR_API_KEY"
```

```json theme={null}
{
  "data": {
    "range": { "from": "2026-08-01", "to": "2026-08-11" },
    "tiles": {
      "attempts": { "value": 1284, "delta_pct": 12.4 },
      "connect_rate": { "value": 0.6231, "delta_pct": -3.1 },
      "avg_duration_s": { "value": 96.4, "delta_pct": 1.8 },
      "cost_credits": { "value": 812.55, "delta_pct": 9.7 }
    },
    "outcomes": {
      "completed": 742, "no_media": 38, "no_answer": 301, "busy": 44,
      "declined": 61, "failed": 52, "user_disconnected": 40, "expired": 6
    },
    "latency": { "p50_ms": 940, "p95_ms": 2180, "sessions": 742 }
  }
}
```

* **`delta_pct`** compares the range against the immediately preceding range of the same length.
* **`connect_rate`** is a fraction, not a percentage. A call counts as connected when a media path was established — `completed`, `no_media` and `user_disconnected`.
* **`avg_duration_s`** averages over connected calls only, so unanswered dials don't drag it toward zero.
* **`latency`** is the agent's end-to-end response latency; `sessions` is how many calls contributed, since not every call reports it.

## Trend

`GET /analytics/overview/trend` returns the same volume figures as one row per UTC day, gap-filled with zeroes so a chart doesn't have to:

```json theme={null}
{
  "data": {
    "range": { "from": "2026-08-01", "to": "2026-08-11" },
    "series": [
      { "day": "2026-08-01", "attempts": 112, "connected": 71, "avg_duration_s": 94.2, "cost_credits": 70.15 }
    ]
  }
}
```

<Note>
  Recent days are computed live while older days are read from a sealed daily rollup. The split is invisible in the response, but it is why a query that includes today can be marginally slower than one that doesn't.
</Note>

<CardGroup cols={2}>
  <Card title="Sessions" icon="phone" href="/concepts/sessions">The per-call record these totals aggregate.</Card>
  <Card title="Billing" icon="credit-card" href="/concepts/billing">How `cost_credits` is metered.</Card>
</CardGroup>
