Query account data
query_account_dataRead this account's data. Returns JSON rows. Use it for counts, breakdowns and lists across leads, calls, texts, reps and teams — look things up rather than guessing. Prefer the specialised tools where one fits: query_reports for report metrics (connection rate, talk time, per-rep performance, computed as the Reports page does); search_leads to find a particular lead; get_lead for one lead's full profile (tags, custom fields, notes); get_recording for a call's recording and transcript.
Two modes:
List rows: give
select(or leave it out for sensible defaults),filters,order_by,limit.Aggregate: give
group_byand/oraggregates. With onlyaggregatesyou get one summary row.
Dates: date_from / date_to are YYYY-MM-DD in the account's timezone (America/Phoenix), both inclusive, applied to the resource's default date column unless date_field names another. All stored times are UTC; time buckets in group_by are converted to the account's timezone.
group_by entries: a column name, or a time bucket written bucket:column where bucket is one of hour, day, week, month, hour_of_day, day_of_week (1 = Sunday).
aggregates entries: count, or function:column where function is count_distinct, sum, avg, min or max (e.g. avg:seconds, count_distinct:lead_id). Each comes back as a column named like avg_seconds.
filters: objects {field, op, value?, values?}. op is one of eq, neq, gt, gte, lt, lte, in, not_in, contains, starts_with, is_null, not_null. Use values for in / not_in. Booleans are 1 / 0.
order_by: a column or an aggregate's output name (e.g. count); order_dir asc or desc.
Ids point at other resources (e.g. calls.user_id is users.id, profile_id is teams.id): query those to turn ids into names. To learn what values a column holds, group by it.
Resources:
leads: People who came in to be called (web forms, CRMs, API, inbound calls). Default date column: created_at. Columns: id (lead id); profile_id (team the lead is routed to (teams.id)); original_profile_id (team the lead first arrived on (teams.id)); lead_owner_id (owning rep (users.id)); fname (first name); lname (last name); email (email); phone_number (E.164 phone number); company (company); category (category); source (where the lead came from (form, integration name, api, inbound)); crm (CRM the lead was synced from, if any); status (lead status); result (latest call result); outcome (latest disposition); stage_id (pipeline stage (stages.id)); sequence_id (follow-up sequence enrolled in (sequences.id)); current_attempt (number of call attempts so far); response_time (seconds from lead creation to first call); is_blocked (1 when the number is blocked); is_stopped (1 when follow-ups were stopped); is_sms_stopped (1 when the lead opted out of SMS); next_followup_at (next scheduled follow-up (UTC)); called_at (first called (UTC)); contacted_at (first reached a human (UTC)); created_at (created (UTC)); updated_at (last updated (UTC))
calls: Every call: speed-to-lead dispatches, AI calls, follow-ups, inbound and manual calls. One row per call, with the outcome. Default date column: created_at. Columns: id (call id); lead_id (lead (leads.id)); profile_id (team (teams.id)); user_id (rep who took the call (users.id), null if nobody answered or an AI handled it); ai_agent_id (AI agent that handled it (ai_agents.id)); number_id (Callingly number involved (numbers.id)); integration_id (integration that triggered it (integrations.id)); phone_number (lead phone number); direction (inbound or outbound); type (call type); source (what started the call); status (call status); ring_status (team ring status); lead_status (lead leg status); human_result (result recorded by the rep); machine_result (answering-machine detection result); is_voicemail (1 when it reached voicemail); seconds (talk time in seconds); minutes (billed minutes); response_time (seconds from lead creation to this call); scheduled_call_type (kind of scheduled follow-up this call was, if any); is_ai_screened (1 when an AI screened the lead first); is_ai_only (1 when only the AI handled it); is_human_only (1 when only humans handled it); is_ai_handed_off (1 when the AI warm-transferred to a rep); ai_outcome (AI call outcome (e.g. transferred, scheduled, voicemail, not interested)); ai_call_type (AI call type); is_error (1 when the call errored); error_code (error code); stage_id (stage set on the call (stages.id)); tag_id (tag set on the call (tags.id)); summary (AI summary of the conversation); transcript (full transcript (long; select only for a few calls)); started_at (started (UTC)); ended_at (ended (UTC)); created_at (created (UTC))
call_legs: One row per rep rung on a call: who was rung, whether they answered, how long it rang. Use for rep answer rates and missed calls. Default date column: created_at. Columns: id (leg id); call_id (call (calls.id)); user_id (rep rung (users.id)); type (device rung); is_called (1 when the rep was actually rung); is_answered (1 when the rep picked up); is_accepted (1 when the rep accepted the call); is_voicemail (1 when the rep leg went to voicemail); is_busy (1 when the rep was busy); is_offline (1 when the rep was offline); is_dnd (1 when the rep was on do-not-disturb); is_canceled (1 when the leg was cancelled (another rep answered first)); is_error (1 when the leg errored); seconds (talk seconds on this leg); queue_time (seconds in queue); ringing_at (started ringing (UTC)); answered_at (answered (UTC)); created_at (created (UTC))
sms: Text messages sent and received. Default date column: created_at. Columns: id (message id); lead_id (lead (leads.id)); user_id (rep who sent it (users.id), null for automated or inbound); direction (inbound or outbound); status (delivery status); from (sending number); to (receiving number); body (message text); source (what sent it (sequence, AI, rep, …)); is_error (1 when delivery failed); error_code (carrier error code); sent_at (sent (UTC)); created_at (created (UTC))
scheduled_calls: Upcoming follow-up calls and callbacks that have not been placed yet. Default date column: scheduled_at. Columns: id (scheduled call id); lead_id (lead (leads.id)); profile_id (team (teams.id)); lead_owner_id (owning rep (users.id)); type (follow-up type); source (what scheduled it); scheduled_at (when it will be placed (UTC)); is_queued (1 when already queued to dial); is_sms_only (1 when it only sends a text); is_ai_only (1 when an AI will place it); is_human_only (1 when only humans will be rung); created_at (created (UTC))
scheduled_sms: Texts queued to send later. Default date column: send_at. Columns: id (id); lead_id (lead (leads.id)); user_id (rep who scheduled it (users.id)); number_id (sending number (numbers.id)); body (message text); send_at (when it sends (UTC)); sent_at (when it was sent (UTC)); is_error (1 when sending failed); created_at (created (UTC))
notes: Notes on leads. Default date column: created_at. Columns: id (note id); lead_id (lead (leads.id)); call_id (call (calls.id)); user_id (author (users.id)); content (note text); created_at (created (UTC))
activities: The lead timeline: every event recorded against a lead. Default date column: created_at. Columns: id (id); lead_id (lead (leads.id)); user_id (user involved (users.id)); call_id (call (calls.id)); action (event type); actor (who did it); interface (where it happened (web, app, api, …)); message (description); created_at (created (UTC))
users: Everyone with a login on the account (owners, admins, managers, agents). Default date column: created_at. Columns: id (user id); fname (first name); lname (last name); email (email); role (owner, admin, manager or agent); phone_number (phone number calls ring); timezone (timezone); is_online_web (1 when online in the browser); is_online_app (1 when online in the desktop app); is_online_mobile_app (1 when online in the mobile app); donotdisturb (1 when on do-not-disturb); last_login (last login (UTC)); last_called_at (last rung (UTC)); created_at (created (UTC))
teams: Teams: the ring groups leads are routed to, each with its own call settings. Default date column: created_at. Columns: id (team id); name (team name); call_mode (how reps are rung); sequence_id (follow-up sequence (sequences.id)); ai_agent_id (assigned AI agent (ai_agents.id)); fallback_id (fallback team (teams.id)); timezone (team timezone); language (whisper language); is_record (1 when calls are recorded); is_ai_call_submitted (1 when the AI calls new leads); is_ai_call_after_hours (1 when the AI calls after hours); is_ai_call_follow_ups (1 when the AI places follow-ups); is_ai_call_after_retries (1 when the AI calls after human retries run out); created_at (created (UTC))
team_members: Which users are on which team. Default date column: created_at. Columns: profile_id (team (teams.id)); user_id (member (users.id)); priority (ring priority); cap (daily lead cap)
ai_agents: AI voice agents configured on the account. Default date column: created_at. Columns: id (agent id); name (internal name); first_name (name the agent introduces itself with); company (company it speaks for); is_voicemail (1 when it leaves voicemails); created_at (created (UTC))
sequences: Automated call + SMS follow-up sequences. Default date column: created_at. Columns: id (sequence id); name (name); created_at (created (UTC))
numbers: Phone numbers the account owns. Default date column: created_at. Columns: id (number id); name (label); phone_number (E.164 number); type (number type); team_id (team inbound calls route to (teams.id)); routing (inbound routing mode); is_record (1 when calls are recorded); is_dispatch (1 when used as a dispatch caller ID); ai_voice_agent_id (AI agent answering inbound calls (ai_agents.id)); ai_sms_agent_id (AI agent answering texts (ai_agents.id)); created_at (created (UTC))
tags: Lead tags. Default date column: created_at. Columns: id (tag id); name (name); is_cancel_calls (1 when tagging a lead cancels its calls); created_at (created (UTC))
lead_tags: Which tags are on which leads. Default date column: created_at. Columns: lead_id (lead (leads.id)); tag_id (tag (tags.id)); created_at (tagged (UTC))
stages: Pipeline stages. Default date column: created_at. Columns: id (stage id); name (name); order (position in the pipeline); close_percent (close probability); is_funnel (1 when shown in the funnel)
integrations: Connected lead sources and CRMs. Default date column: created_at. Columns: id (integration id); profile_id (team leads route to (teams.id)); platform (platform (e.g. hubspot, followupboss, zapier)); name (label); status (connection status); is_installed (1 when installed); created_at (created (UTC))
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max rows, up to 200. Default 50. | |
| select | No | Columns to return when listing rows. | |
| date_to | No | YYYY-MM-DD, inclusive, account timezone. | |
| filters | No | ||
| group_by | No | ||
| order_by | No | ||
| resource | Yes | ||
| date_from | No | YYYY-MM-DD, inclusive, account timezone. | |
| order_dir | No | ||
| aggregates | No | ||
| date_field | No | Date column the date range applies to; defaults to the resource's date column. |