Skip to content

Analytics

Track call volume, platform-minute usage, carrier spend, sentiment distribution, and agent performance metrics.

Spend Overview

GET/v1/analytics/spend

Returns aggregated metrics across calls for the authenticated tenant. Filter by date range, agent, or call status.

Query Parameters

ParameterTypeRequiredDefaultDescription
fromstringNoNoneInclusive start date in YYYY-MM-DD format. When omitted, no start bound is applied and all calls are aggregated (the time_series window still defaults to 30 days ago).
tostringNoNoneInclusive end date in YYYY-MM-DD format. When omitted, no end bound is applied and all calls are aggregated (the time_series window still defaults to today).
agent_iduuidNoAll agentsRestrict metrics to a specific agent
statusstringNoAll statusesFilter by call status: completed, failed, in_progress

Example Request

bash
curl "https://api.rymi.live/v1/analytics/spend?from=2026-03-01&to=2026-03-31&agent_id=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response 200

json
{
  "total_calls": 140,
  "completed_calls": 120,
  "in_progress_calls": 2,
  "average_duration_seconds": 187,
  "success_rate": 0.72,
  "total_minutes": 1450,
  "customer_revenue": 58.0,
  "provider_cost": 46.5,
  "gross_margin": 11.5,
  "gross_margin_pct": 19.83,
  "time_series": [
    {
      "date": "2026-03-01",
      "calls": 8,
      "minutes": 34,
      "customer_revenue": 2.4,
      "provider_cost": 1.9,
      "gross_margin": 0.5
    }
  ],
  "status_distribution": {
    "completed": 120,
    "failed": 18,
    "in_progress": 2
  },
  "sentiment_distribution": {
    "positive": 40,
    "neutral": 61,
    "negative": 8,
    "unknown": 31
  },
  "end_reason_distribution": {
    "caller_hangup": 72,
    "agent_ended": 40,
    "error": 8
  },
  "agent_performance": [
    {
      "agent_id": "550e8400-e29b-41d4-a716-446655440000",
      "calls": 90,
      "minutes": 740.5,
      "customer_revenue": 31.2,
      "provider_cost": 25.1,
      "gross_margin": 6.1,
      "evaluated_calls": 64,
      "passed_calls": 46,
      "success_rate": 0.719,
      "sentiment": { "positive": 30, "neutral": 48, "negative": 6, "unknown": 6 },
      "sentiment_score": 0.286
    }
  ],
  "drop_off_points": [
    { "bucket": "<30s", "count": 3 },
    { "bucket": "30-60s", "count": 7 },
    { "bucket": "60-120s", "count": 25 },
    { "bucket": ">120s", "count": 45 }
  ],
  "filters": {
    "from": "2026-03-01",
    "to": "2026-03-31",
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "status": null
  }
}

Response Fields

FieldTypeDescription
total_callsintegerTotal call count matching the filters
completed_callsintegerCalls that completed successfully
in_progress_callsintegerCalls currently active
average_duration_secondsintegerAverage call duration in seconds
success_ratenumberRatio of evaluated calls that passed their evaluation (0.0–1.0)
total_minutesnumberTotal billed minutes across completed calls
customer_revenuenumberTotal customer-billed revenue in USD across completed calls
provider_costnumberTotal underlying provider cost in USD across completed calls
gross_marginnumbercustomer_revenue − provider_cost in USD
gross_margin_pctnumber | nullGross margin as a percentage of revenue; null when revenue is 0
time_seriesarrayDaily breakdown: { date, calls, minutes, customer_revenue, provider_cost, gross_margin }
status_distributionobjectCall count grouped by final status
sentiment_distributionobjectCall count grouped by post-call sentiment (positive, neutral, negative, unknown)
end_reason_distributionobjectCall count grouped by why the call ended (e.g. caller_hangup, agent_ended)
agent_performancearrayPer-agent breakdown: { agent_id, calls, minutes, customer_revenue, provider_cost, gross_margin, evaluated_calls, passed_calls, success_rate, sentiment, sentiment_score }
drop_off_pointsarrayDuration histogram of non-passing calls, bucketed <30s, 30-60s, 60-120s, >120s
filtersobjectEcho of applied filters

Errors

StatusMeaning
401Missing or invalid API key
500Server error while querying analytics

INFO

Analytics data is aggregated from call records plus post-call intelligence. Real-time minute counts may be supplemented from live usage tracking when available.

Cost Scope

provider_cost (and the derived gross_margin/gross_margin_pct) are aggregated from each completed call's recorded provider_cost. For self-serve BYOC, this reflects carrier spend only when the connected provider reports costs and the gateway persists them. LLM/STT/TTS provider token-level cost metering is on the roadmap.