Dashboard Timeseries
Returns daily aggregated data points from call_stats_daily for charting. Each entry represents one day's stats. The frontend can request only specific metrics to reduce payload size.
Endpoint
| Property | Value |
|---|---|
| Function Name | dashboard-timeseries |
| HTTP Method | GET |
| Authentication | Supabase JWT (Bearer token) |
Request
Headers
Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
period | string | No | 7d | today, 7d, 30d, 90d, or custom |
start_date | string (ISO date) | If period=custom | -- | Start date YYYY-MM-DD |
end_date | string (ISO date) | If period=custom | -- | End date YYYY-MM-DD |
metrics | string | No | all | Comma-separated column names to include |
campaign_id | string (UUID) | No | -- | Filter to a specific campaign |
client_id | string (UUID) | No | -- | Filter to a specific client |
Available Metrics
total_calls, completed_calls, failed_calls, connected_calls,
conversations_had, meetings_booked, qualified_leads,
total_duration_seconds, avg_duration_seconds,
inbound_calls, outbound_calls,
positive_sentiment_calls, neutral_sentiment_calls, negative_sentiment_calls,
objections_encountered, issues_resolved, escalations,
voicemail_calls, callback_requested_calls, not_interested_calls,
wrong_number_calls, dnc_requested_calls, gatekeeper_blocked_calls,
no_answer_calls, conversation_calls,
avg_talk_ratio, avg_listen_ratio, total_interruptions,
avg_script_adherence, total_objections_handled, total_buying_signals,
emails_sent, sms_sent
Response
Success (200)
{
"period": { "start_date": "2026-02-10", "end_date": "2026-02-16" },
"data": [
{
"date": "2026-02-10",
"total_calls": 22,
"connected_calls": 16,
"meetings_booked": 2
},
{
"date": "2026-02-11",
"total_calls": 18,
"connected_calls": 12,
"meetings_booked": 1
}
// ... one entry per day that has data
]
}
Days with zero calls will not have an entry. Fill gaps with zeros on the frontend if needed.
Error Responses
| Status | Condition |
|---|---|
| 401 | Missing or invalid authorization header |
| 403 | User exists but has no agency_id |
| 405 | HTTP method is not GET |
| 500 | Failed to query call_stats_daily |
Behavior
- Authenticates the user via Supabase JWT and resolves their
agency_id. - Parses the optional
metricsparameter. Invalid metric names are silently ignored; if none are valid, all metrics are returned. - Queries
call_stats_dailyordered bystat_dateascending. - Aggregates multiple rows for the same date (e.g., different client/campaign combinations) into a single row per day.
- For count fields, values are summed. For
avg_*fields, weighted averages are computed usingcompleted_callsas the weight. - Internal weight tracking fields are stripped from the final response.
Database Tables
| Table | Operation | Description |
|---|---|---|
users | Read | Fetches user profile to determine agency_id |
call_stats_daily | Read | Pre-aggregated daily stats, dynamically selecting requested metrics |
External APIs
None.
Related Functions
- Dashboard Overview -- Summary KPIs (call on same page load)
- Dashboard Funnel -- Conversion funnel (call on same page load)
- Dashboard Quality -- Quality analytics with its own trends
- Frontend API Guide -- Recommended
metricsparam per chart type