Skip to main content

Dashboard Funnel

Returns conversion funnel data showing progression from total calls through to booked appointments. Includes both absolute counts at each stage and step-to-step conversion rates.

Endpoint

PropertyValue
Function Namedashboard-funnel
HTTP MethodGET
AuthenticationSupabase JWT (Bearer token)

Request

Headers

Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json

Query Parameters

ParameterTypeRequiredDefaultDescription
periodstringNo7dtoday, 7d, 30d, 90d, or custom
start_datestring (ISO date)If period=custom--Start date YYYY-MM-DD
end_datestring (ISO date)If period=custom--End date YYYY-MM-DD
campaign_idstring (UUID)No--Filter to a specific campaign
client_idstring (UUID)No--Filter to a specific client

Response

Success (200)

{
"period": { "start_date": "2026-02-10", "end_date": "2026-02-16" },
"funnel": {
"total_calls": 150,
"connected": 110,
"conversation": 85,
"qualified": 25,
"appointment_booked": 12
},
"rates": {
"contact_rate": 73.3, // % total -> connected
"connected_to_conversation": 77.3, // % connected -> conversation
"conversation_to_qualified": 29.4, // % conversation -> qualified
"qualified_to_booked": 48.0, // % qualified -> booked
"overall_conversion": 8.0 // % total -> booked
}
}

Funnel Stages

Total Calls (150) -> Connected (110) -> Conversation (85) -> Qualified (25) -> Booked (12)
73.3% 77.3% 29.4% 48.0%

Error Responses

StatusCondition
401Missing or invalid authorization header
403User exists but has no agency_id
405HTTP method is not GET
500Failed to query call_stats_daily

Behavior

  • Authenticates the user via Supabase JWT and resolves their agency_id.
  • Queries call_stats_daily selecting only the funnel-relevant columns: total_calls, connected_calls, conversations_had, qualified_leads, meetings_booked.
  • Sums all matching rows to produce aggregate funnel counts.
  • Computes step-to-step conversion rates. Division by zero returns 0.

Database Tables

TableOperationDescription
usersReadFetches user profile to determine agency_id
call_stats_dailyReadPre-aggregated daily stats, filtered by agency/date/campaign/client

External APIs

None.