# Analytics API

> NPS trend, branch leaderboard, custom call metrics and call volume.

Aggregated dashboard metrics for the organization behind your API key. Read-only.

- Base path: `/analytics/v1/` (REST) or Connect/gRPC `pingx.analytics.v1.AnalyticsService`.
- Auth: `Authorization: Bearer <key>`; scope `analytics:read` (or `analytics`).
- Returns the same figures as the Analytics page in the app.

| RPC | REST | Scope |
|---|---|---|
| GetNpsTrend | `GET /analytics/v1/nps-trend?days=` | read |
| GetBranchLeaderboard | `GET /analytics/v1/branch-leaderboard?days=` | read |
| GetCustomMetrics | `GET /analytics/v1/custom-metrics?days=&agentId=&humanOperatorsOnly=` | read |
| GetCallVolume | `GET /analytics/v1/call-volume?days=` | read |

Conventions: `days` is a lookback in calendar days ending today (default 30, max 180, clamped; the
effective value is echoed as `days`). Points carry RFC 3339 dates. NPS is -100..100; a day or window
with `responses = 0` reports `nps = 0` (check `responses`). int64 values are JSON strings.

Out of scope: call listing/transcripts (voice API) and WhatsApp message stats (WhatsApp API).

