Retrieve campaign KPIs

View as Markdown
The KPIs defined for the campaign's category (e.g. `revenue_total`, `avg_ticket` for `sales`), aggregated over the calls of the last `days` days, plus `breakdown`: for each distribution KPI (e.g. `best_product`), the share of calls per label. Plot one KPI over time with `GET /api/analytics/kpi/{campaignId}/timeseries`; see which fields feed each category with `GET /api/analytics/kpi/templates/{category}`. - `value` is the sum for `sum` KPIs, the average (two decimals) for `avg` KPIs, and equals `count` for `count` KPIs. KPIs ending in `_today` cover the current UTC day only. - `breakdown` items are sorted by `count` descending; `percentage` is the share (0-100, two decimals) of all labelled calls for that KPI. Distribution labels are the values the agent extracted (Spanish product text). **No data.** Every KPI of the category is always listed; with no samples its `value` and `count` are `0` (not `null`) — read `count` to tell "nothing measured" from a real zero. A distribution KPI with no labelled calls has `[]` in `breakdown`. An unknown, deleted or other workspace's campaign id is NOT a `404`: it is reported with category `general` and zero values. **Idempotency.** Read-only; safe to retry. **Consistency.** Cached 120 seconds per campaign and `days`; cleared whenever a call of the campaign has its KPIs processed. **Access** - **Required scope:** `read`. Signed-in users need the owner, admin, member or viewer role. - **Rate limit:** Analytics — 30 requests/min per workspace, shared with the rest of `/api/analytics/*` (except `/analysis/*`); a KPI request consumes 2 units, so effectively 15 requests/min. Also counts against the general API limit. See [Rate limits](/rate-limits). - **Plan:** Available on every plan (behind the `advancedDashboard` feature gate, which is enabled on every plan).

Authentication

AuthorizationBearer
Workspace API key: `jl_` followed by 64 lowercase hex characters, created by the workspace owner in the dashboard (**Settings → API Keys**) and sent as `Authorization: Bearer jl_...`. The plaintext is shown once, at creation; Jelliu stores only a SHA-256 hash. A workspace can hold up to 25 active keys. | Scope | GET / HEAD | POST / PUT / PATCH / DELETE | Admin-only routes | | --- | --- | --- | --- | | `read` | Yes | No | No | | `write` | Yes | Yes | No | | `full` | Yes | Yes | Yes | Operations restricted to admins or owners reject keys without the `full` scope with `403`, and say so in their description. No key, whatever its scope, can mint or revoke API keys or rotate a webhook secret — that requires a signed-in owner session. A revoked key stops authenticating within about 10 seconds. See [Authentication](/authentication).

Path parameters

campaignIdstringRequiredformat: "uuid"

UUID of the campaign (see GET /api/campaigns). A non-UUID is a 400; a well-formed id that is unknown or belongs to another workspace returns zero-valued general KPIs, not a 404.

Query parameters

daysintegerOptional1-365Defaults to 30

Look-back window in days. Never rejected - a non-integer, out-of-range (1-365) or non-numeric value falls back to 30.

Response

Campaign KPIs.
dataobjectOptional

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error