Query Contacts
This endpoint retrieves a paginated list of contacts associated with the authenticated user’s company. It provides powerful filtering capabilities to segment your contact database by tags, categories, source names, and recent call activity. This is ideal for targeted campaign creation, lead qualification workflows, and comprehensive contact management.Endpoint Details
- URL:
/contacts/query - Method:
GET - Authentication: Required (
API KEYorJWT Token) - Source:
src/api/public_apis_v1/contact/company_contacts/company_contacts_controller.rs - Pagination: Supports page-based pagination with customizable page size
Key Features
- Advanced Filtering: Filter contacts by multiple criteria simultaneously
- Pagination Support: Efficiently retrieve large contact lists with page-based navigation
- Search Capability: Full-text search across contact names and phone numbers
- Call Status Tracking: Filter by last call outcome to identify follow-up opportunities
- Source Attribution: Track and filter by contact acquisition sources
- Tag & Category Management: Organize contacts using custom tags and categories
Request Headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer <api_key> | Your API KEY or JWT Token |
Content-Type | application/json | Request content type |
Query Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
source_name | String | No | Filter contacts by their acquisition source | "Website Form", "CSV Import", "Manual" |
search | String | No | Search term matching firstname, lastname, or phone number | "John", "+1234567890" |
last_call_statuses | String | No | Comma-separated list of call statuses to filter by | "completed,busy,no-answer" |
page | Integer | No | Page number for pagination (0-indexed) | 0, 1, 2 (default: 0) |
per_page | Integer | No | Number of contacts per page | 10, 50, 100 (default: 20) |
tags | String | No | Comma-separated list of tags to filter by | "hot_lead,vip" |
categories | String | No | Comma-separated list of categories to filter by | "sales_qualified,marketing_qualified" |
Filter Behavior
- Multiple Filters: When multiple filters are applied, they work as AND conditions (contacts must match all criteria)
- Multiple Values: Within a single filter parameter (e.g., tags), multiple values work as OR conditions (contacts can match any value)
- Case Sensitivity: Search and filter parameters are case-insensitive
- Partial Matching: The search parameter performs partial matching on names and phone numbers
Example Requests
Basic Request - Get First Page
Filter by Source
Search for Specific Contact
Filter by Call Status
Advanced Filtering
JavaScript/TypeScript Example
Python Example
Response
Success Response
Status Code:200 OK
Error Response
Status Code:200 OK (with error status)
Response Fields
Pagination Object
| Field | Type | Description |
|---|---|---|
total_count | Integer | Total number of contacts matching the filter criteria |
data | Array | Array of contact objects for the current page |
Contact Object Fields
| Field | Type | Description |
|---|---|---|
id | UUID | Unique identifier for the contact |
company_id | UUID | Company that owns this contact |
firstname | String | Contact’s first name |
lastname | String | Contact’s last name |
phone_number | String | Contact’s phone number in E.164 format |
metadata | Object | Custom metadata fields (email, company, job title, etc.) |
number_country_code | String | Country code of the phone number |
last_call_status | String | Status of most recent call (completed, busy, no-answer, etc.) |
last_call_at | DateTime or null | Timestamp of the last call |
last_call_duration | Integer or null | Duration of last call in seconds |
last_call_feedback | String or null | Feedback from the most recent call |
source_name | String | Source where contact was acquired |
tag_name | String | Tag label for categorization |
category_name | String | Category classification |
notes | String or null | Additional notes about the contact |
created_at | DateTime | Timestamp when contact was created |
updated_at | DateTime | Timestamp when contact was last updated |
campaign_id | UUID or null | Associated campaign identifier |
status | String | Contact status (active, inactive) |
workspace_id | String | Workspace identifier |
Use Cases
1. Lead Segmentation
Query contacts by tags and categories to create targeted segments for specific campaigns:2. Follow-Up Lists
Identify contacts who need follow-up based on their last call status:3. Source Analysis
Analyze contact acquisition by filtering by source:4. Contact Search
Search for specific contacts by name or phone number:5. Campaign Preparation
Build targeted lists for new campaigns by combining multiple filters:6. CRM Export
Paginate through all contacts for data export or synchronization:Pagination Best Practices
Calculating Total Pages
Iterating Through All Pages
Common Call Statuses
| Status | Description | Follow-Up Action |
|---|---|---|
completed | Call was successfully completed | Review feedback, schedule follow-up if needed |
busy | Contact’s line was busy | Retry during different time |
no-answer | Contact didn’t answer | Retry at different time of day |
failed | Call failed to connect | Check phone number validity |
voicemail | Call went to voicemail | Leave message and mark for follow-up |
never_called | Contact has never been called | Prime candidate for new campaigns |
Notes
- Performance: For large datasets, use reasonable
per_pagevalues (20-100) to balance response time and number of requests - Pagination Index: Page numbering starts at 0 (first page is page=0)
- Filter Combinations: Multiple filters are applied as AND conditions - contacts must match all specified criteria
- Empty Results: An empty data array with total_count=0 indicates no contacts match the filters
- Rate Limiting: Consider implementing rate limiting when paginating through large datasets
- Timestamps: All timestamps are in UTC format
- Metadata Flexibility: The metadata field can contain any custom JSON structure
- Search Performance: The search parameter performs case-insensitive partial matching across multiple fields