Reference

Analytics

Flexible analytics queries for aggregating call data across templates, merchants, and time ranges.

Overview

The analytics API provides a unified query interface for aggregating call data. All queries are submitted via a single endpoint with a structured query body supporting filtering, pagination, and time granularity.

Query endpoint

POST /analytics

Supported Query Types

Query TypeDescription
call_countTotal number of calls matching filters.
call_durationAggregate duration statistics (avg, min, max, total).
outcome_distributionBreakdown of call outcomes.
sentiment_distributionSentiment score distribution.
status_distributionLead status breakdown.
calls_over_timeCall count grouped by time granularity.
avg_duration_over_timeAverage duration grouped by time granularity.
top_outcomesMost frequent outcomes ranked by count.
retry_analysisRetry attempt distribution and success rates.
provider_breakdownCall volume by telephony provider.
hourly_heatmapCall distribution by hour of day.
conversion_funnelLead progression through statuses.

Filter Options

FilterTypeDescription
template_idstringFilter by template.
merchant_idstringFilter by merchant.
reseller_idstringFilter by reseller.
date_fromstring (ISO 8601)Start of date range.
date_tostring (ISO 8601)End of date range.
min_durationintMinimum call duration in seconds.
max_durationintMaximum call duration in seconds.
sentiment_minfloatMinimum sentiment score (0.0–1.0).
sentiment_maxfloatMaximum sentiment score (0.0–1.0).
payload_filtersobjectFilter on arbitrary payload fields (e.g. {"city": "Mumbai"}).

Example Query

json
{
  "query_type": "calls_over_time",
  "filters": {
    "template_id": "tpl_xyz789",
    "merchant_id": "mer_abc",
    "date_from": "2025-01-01T00:00:00Z",
    "date_to": "2025-01-31T23:59:59Z",
    "min_duration": 10
  },
  "granularity": "day",
  "page": 1,
  "page_size": 31
}

Example Response

json
{
  "query_type": "calls_over_time",
  "data": [
    { "date": "2025-01-01", "count": 42 },
    { "date": "2025-01-02", "count": 58 },
    { "date": "2025-01-03", "count": 37 }
  ],
  "total": 31,
  "page": 1,
  "page_size": 31
}

Payload Filters

Use payload_filters to query on custom fields from your lead payloads. For example, filter by city, plan type, or any key-value pair you include when pushing leads.

Error responses

StatusMeaningCommon Cause
400Bad RequestInvalid query type or malformed filters.
422Unprocessable EntityInvalid date range or filter values.
Was this helpful?