Dashboard Quality
Returns aggregate call quality metrics and a daily trend breakdown. Covers talk-to-listen ratio, script adherence, sentiment distribution, interruptions, objection handling, and duration stats.
Endpoint
| Property | Value |
|---|---|
| Function Name | dashboard-quality |
| 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 |
campaign_id | string (UUID) | No | -- | Filter to a specific campaign |
client_id | string (UUID) | No | -- | Filter to a specific client |
Response
Success (200)
{
"period": { "start_date": "2026-02-10", "end_date": "2026-02-16" },
"quality": {
"avg_duration_seconds": 180,
"avg_talk_ratio": 0.5500, // 0-1
"avg_listen_ratio": 0.4500, // 0-1
"avg_script_adherence": 0.7200, // 0-1
"total_interruptions": 45,
"avg_interruptions_per_call": 0.38,
"objection_handling_rate": 60.0, // %
"total_buying_signals": 40,
"sentiment_distribution": {
"positive": 72,
"neutral": 36,
"negative": 11,
"positive_pct": 60.5, // %
"neutral_pct": 30.3, // %
"negative_pct": 9.2 // %
}
},
"trend": [
{
"date": "2026-02-10",
"avg_duration_seconds": 165,
"avg_talk_ratio": 0.5800,
"avg_script_adherence": 0.7000,
"sentiment_positive_pct": 55.0,
"interruptions": 8,
"completed_calls": 18
}
// ... one entry per day
]
}
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. - Queries
call_stats_dailyselecting quality-specific columns, ordered bystat_dateascending. - Computes aggregate quality metrics using weighted averages (weighted by
completed_calls) for ratio fields and sums for count fields. - Builds a daily trend array by aggregating multiple rows per date into one. Each trend entry includes averaged metrics for that day plus raw
completed_callscount. - Sentiment distribution includes both raw counts and computed percentages.
Database Tables
| Table | Operation | Description |
|---|---|---|
users | Read | Fetches user profile to determine agency_id |
call_stats_daily | Read | Pre-aggregated daily stats with quality metrics |
External APIs
None.
Related Functions
- Dashboard Overview -- Summary quality metrics (lighter version)
- Dashboard Heatmap -- Best times to call (same page)
- Dashboard Objections -- Objection analysis (same page)
- Frontend API Guide -- Quality page endpoint mapping