Query Calls
This endpoint provides powerful filtering and querying capabilities for retrieving call records with support for pagination, sorting, searching, and advanced column-based filtering.Endpoint Details
- URL:
/calls/query
- Method:
GET
- Authentication: Required (
API KEY
orJWT Token
) - Source:
src/types/calls_services/query.rs
Query Parameters
Basic Filters
Parameter | Type | Description | Example |
---|---|---|---|
campaign_id | UUID (optional) | Filter by specific campaign | 550e8400-e29b-41d4-a716-446655440000 |
ai_agent_id | UUID (optional) | Filter by specific AI agent | 550e8400-e29b-41d4-a716-446655440001 |
status | String (optional) | Filter by call status (case-insensitive partial match) | completed , failed , in-progress |
search | String (optional) | Search across multiple fields (call_to, notes, feedback, transcript) | John Doe or +1234567890 |
Date Range Filters
Parameter | Type | Description | Example |
---|---|---|---|
start_date | Date (optional) | Filter calls started on or after this date | 2024-01-01 |
end_date | Date (optional) | Filter calls started on or before this date | 2024-12-31 |
Pagination
Parameter | Type | Description | Default | Example |
---|---|---|---|---|
page | Integer | Page number (0-indexed) | 0 | 2 |
per_page | Integer | Number of results per page | 10 | 25 |
Sorting
Parameter | Type | Description | Default | Example |
---|---|---|---|---|
sort_column | String | Column to sort by | created_at | See supported columns below |
order | String | Sort order | desc | asc or desc |
Supported Sort Columns
name
(sorts by call_to)created_at
updated_at
started_at
ended_at
call_duration
call_sid
call_from
call_to
call_provider
call_status
call_direction
call_rating
call_feedback
record_url
transcript
transcript_language
is_test
cost
price_unit
latency
disconnect_reason
analysis_sentiment
agent_task_status
agent_task_feedback
metadata
notes
agent_dynamic_variables
agent_post_call_outcomes
retry_at
Advanced Column Filtering
The API supports dynamic filtering on specific columns using three array parameters that work together:Parameter | Type | Description |
---|---|---|
filter_columns[] | Array<String> | Column names to filter on |
filter_values[] | Array<String> | Values to filter for (parallel to columns) |
filter_operator[] | Array<String> | Operators to use (parallel to columns) |
Supported Filter Columns
Text Fields
Columns:call_direction
, call_status
, call_to
, call_from
, transcript
, notes
, call_feedback
, call_sid
, call_provider
, disconnect_reason
, analysis_sentiment
, agent_task_status
, agent_task_feedback
, price_unit
Supported Operators:
EQUALS
- Exact matchNOT_EQUALS
- Not equal to valueCONTAINS
- Contains substring (case-insensitive)NOT_CONTAINS
- Does not contain substringNOT_NULL
- Field has a valueIS_NULL
- Field is null/emptyINCLUDES
- Same as EQUALS (for compatibility)NOT_INCLUDES
- Same as NOT_EQUALS
Numeric Fields
Columns:call_duration
(integer), call_rating
(integer), cost
(float), latency
(integer)
Supported Operators:
EQUALS
- Exact matchNOT_EQUALS
- Not equal to valueGREATER_THAN
- Greater than valueGREATER_OR_EQUAL
- Greater than or equal to valueLOWER_THAN
- Less than valueLOWER_OR_EQUAL
- Less than or equal to valueNOT_NULL
- Field has a valueIS_NULL
- Field is null
Boolean Fields
Column:is_test
Supported Operators:
EQUALS
- Match boolean value (true/false)NOT_EQUALS
- Not equal to boolean valueNOT_NULL
- Field has a valueIS_NULL
- Field is null
UUID Fields
Column:id
Supported Operators:
EQUALS
- Exact UUID matchNOT_EQUALS
- Not equal to UUIDNOT_NULL
- Field has a valueIS_NULL
- Field is null
Automatic Status Updates
The endpoint automatically updates stale call statuses before querying:- Calls with status
in-progress
for more than 360 minutes are marked asended
- Calls with status
pstn-queued
for more than 5 minutes are marked asunreachable
Example Requests
Basic Query
Filter by Campaign and Date Range
Search with Status Filter
Advanced Column Filtering - Multiple Conditions
Complex Query Example
Response
Success Response
Status Code:200 OK
Use Cases
1. Quality Assurance Review
Find all calls with poor ratings for review:2. Cost Analysis
Get expensive calls over $5:3. Failed Call Investigation
Find all failed outbound calls from today:4. Transcript Search
Search for specific keywords in transcripts:5. Performance Monitoring
Find calls with high latency:6. Test Call Exclusion
Get only production calls:7. Sentiment Analysis
Find negative sentiment calls for training:Notes
- The
search
parameter searches across:call_to
,notes
,call_feedback
,agent_task_feedback
, andtranscript
- Excluded statuses: Calls with status
scheduled
orpstn-queued
are automatically excluded from results - All text searches are case-insensitive
- Date filters apply to the
started_at
field - When using multiple filters, they are combined with AND logic
- The maximum
per_page
value should be reasonable (e.g., 100-500) to avoid performance issues
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Filter by AI agent ID
Search term for calls
Filter by call status
Filter by start date (YYYY-MM-DD)
Filter by end date (YYYY-MM-DD)
Filter by campaign ID
Column to sort by
Sort order (asc/desc)
Page number for pagination
Number of items per page
Comma-separated list of columns to filter on
Comma-separated list of values for the filter_columns
Operator for filtering (e.g., eq, neq, gt, lt)
Optional workspace filter. If not provided, it will fall back to use "default".