Skip to main content

Insights API

Operator-facing analytics for your AI agents: how much they cost to run (LLM spend), the revenue they attribute and the margin they return (ROI), how often they resolve a conversation without a human (containment), and how each agent ranks against the rest of your org (comparison & benchmarks). These are read dashboards. They’re served from a database read-replica, so they’re cheap to call but lag the primary by 1-3 seconds. The two PUT endpoints (budget and ROI config) write to the primary and are read-back consistent. Base path: /api/v1/insights Authentication: API key (X-API-Key) or session JWT. Every request is scoped to the caller’s organization; you only ever see your own tenant’s data.

Conventions

These apply to every endpoint below.
  • Money is always integer cents. Fields ending in _cents are whole cents in the org’s wallet currency (returned as currency, e.g. USD). The API never converts to dollars or applies FX — format on the client.
  • Time ranges use from and to as ISO 8601 timestamps with an offset (e.g. 2026-06-01T00:00:00Z). from must be earlier than to, and the window may not exceed 365 days. Omit both to default to the last 30 days ending now; pass only one and the other is backfilled to a 30-day window.
  • Timezone-aware buckets. Day/month boundaries are computed in the org’s billing timezone (returned as timezone), not UTC, so a cap or trend lines up with your local day.
  • Envelope. Responses are wrapped as { "data": { … }, "meta": { "request_id": "…", "timestamp": "…" } }. The shapes below show the data payload.
  • Invalid query parameters return 422 with a details.issues array naming the offending field and a message.

LLM spend

Track how much your AI agents are spending on model calls, where it’s going, and whether you’re on track against a budget.

Overview

GET /api/v1/insights/llm-spend/overview takes no parameters. It returns today’s spend, month-to-date spend with a month-end projection and a vs-previous-period delta, the trailing 7-day spend, and how much of the configured daily cap is used. cap_percentage, projected_month_end_cents, and vs_last_period_percent are null when there’s no cap configured or no historic spend to project from.

Summary

GET /api/v1/insights/llm-spend/summary Returns totals for the whole window plus a groups array, each row carrying group_id, group_label, model, total_tokens, total_cost_cents, and conversation_count, ordered by cost descending.

Timeseries

GET /api/v1/insights/llm-spend/timeseries Returns a series array of { bucket, total_tokens, total_cost_cents } ordered ascending. Hour granularity is capped at a 14-day window — use granularity=day for longer ranges, or you’ll get a 422.

Top conversations

GET /api/v1/insights/llm-spend/top-conversations Returns a conversations array of the most expensive threads, each with conversation_id, agent_id, agent_name, model, total_tokens, total_cost_cents, and started_at for drill-down.

By feature

GET /api/v1/insights/llm-spend/by-feature accepts from and to. It aggregates spend by AI feature/channel (e.g. voice, sms, inbox, kb; events with no channel attributed appear as unknown) so you can see which feature is driving cost. It also returns the current budget config and any threshold_breaches — channels that have crossed their configured per-channel cap.

Budget

GET /api/v1/insights/llm-spend/budget returns the current AI budget config. PUT updates it. All body fields are optional — omitted fields keep their current value (read-merge-write), and the server re-validates on write, so out-of-range values are dropped rather than persisted.

Agent ROI

Attributes outcome revenue to each agent and reports cost, attributed revenue, and margin. GET /agent-roi accepts from, to, and limit (default 50, max 200). GET /agent-roi/timeseries accepts from, to, and an optional agentId to scope the trend to a single agent. Attribution is driven by a value-per-outcome config. PUT /agent-roi/config is a read-merge-write with two optional fields:

Containment & resolution

Reports how often agents handle a conversation without a human handoff (containment), how often a conversation reaches a resolved status or passes a rubric outcome (resolution), and how often it escalates. GET /containment accepts from, to, and limit (default 50, max 200). GET /containment/timeseries accepts from, to, and an optional agentId.

Agent comparison & benchmarks

Ranks agents against each other and against the org baseline on the KPIs already computed above (cost, attributed revenue, margin, containment, resolution, escalation).

See also

  • Analytics API — message-traffic analytics, deliverability, and scheduled reports
  • Billing API — wallet, usage, and invoices