Get contacts by time filters
Retrieve contacts filtered by activity (last message within N days), creation time, or update time. Works across all channels (WhatsApp, Instagram, etc.). At least one of days, created_after, or updated_after is required. For incremental sync, poll with updated_after set to the latest updated_at you have stored: the response includes both created_at and updated_at so you can tell new contacts (created_at > your cursor) apart from updated ones. Results are ordered ascending by updated_at (or created_at) when those filters are used, so you can page forward with limit/offset and advance your cursor safely. Optionally filter by custom field values.
Overview
Retrieve contacts that had their last message within a specified number of days. This endpoint works across all communication channels (WhatsApp, Instagram, Web Chat, SMS, etc.) providing a unified view of recent contact activity. Perfect for identifying active contacts, tracking engagement, and filtering contacts by recency across your entire customer base.Use Cases
- Active Contacts Dashboard: Show contacts who messaged in the last 7, 30, or 90 days
- Engagement Metrics: Track how many contacts are actively engaging
- Re-engagement Campaigns: Find contacts who havenβt messaged recently
- Activity Reports: Generate reports of contact activity over time
- Cross-Channel Analytics: See all active contacts regardless of channel
- CRM Sync: Export recently active contacts to external systems
Authentication
This endpoint requires authentication using an API key. Include your API key in the request header:Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
days | number | Yes | Number of days to filter contacts (1-365) |
stage_id | string | No | Stage ID (UUID) to filter contacts by stage |
pipeline_id | string | No | Pipeline ID (UUID) to filter contacts by pipeline |
Response Structure
Returns an array of contact objects:| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique identifier for the contact |
name | string | Contactβs full name |
phone | string | null | Contactβs phone number |
email | string | null | Contactβs email address |
platform | string | Communication channel (whatsapp, instagram, etc.) |
last_message_at | string (ISO) | Timestamp of the last message sent/received |
chat_status | string | Current chat status (UNATTENDED, ATTENDED, etc.) |
created_at | string (ISO) | Contact creation timestamp |
client_id | string (UUID) | Your organization ID |
ai_customer_id | string (UUID) | Associated customer profile ID |
default_stage_id | string (UUID) | Contactβs default pipeline stage |
blocked | boolean | Whether the contact is blocked |
is_chat_read | boolean | Whether the chat has been read by an agent |
active_ticket_v2 | object | null | Active ticket information (see below) |
Active Ticket Object (active_ticket_v2)
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique identifier for the ticket |
current_stage_id | string | null | Current pipeline stage ID for the ticket |
Example Request
Basic Request (All Contacts)
Request with Stage Filter
Request with Pipeline Filter
Example Response
Common Use Cases
1. Get Contacts from Last 7 Days
2. Track Engagement by Channel
3. Find Unattended Contacts
4. Re-engagement Campaign Data
5. Export to External CRM
6. Filter Contacts by Pipeline Stage
7. Activity Dashboard
Query Parameters Details
Days Parameter
Thedays parameter filters contacts where last_message_at is within the specified number of days from now:
| Days Value | Description | Use Case |
|---|---|---|
1 | Last 24 hours | Todayβs activity |
7 | Last week | Weekly engagement report |
30 | Last month | Monthly active contacts |
90 | Last quarter | Quarterly analysis |
180 | Last 6 months | Semi-annual review |
365 | Last year (maximum allowed) | Annual customer base analysis |
Stage ID Parameter
The optionalstage_id parameter filters contacts by their current pipeline stage. Only contacts with an active ticket in the specified stage will be returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
stage_id | string | No | UUID of the pipeline stage to filter by |
stage_id is provided, only contacts with an active
ticket (active_ticket_v2) in that specific stage are returned. Contacts
without an active ticket or in a different stage are excluded.Pipeline ID Parameter
The optionalpipeline_id parameter filters contacts by the pipeline of their active ticketβs current stage.
| Parameter | Type | Required | Description |
|---|---|---|---|
pipeline_id | string | No | UUID of the pipeline to filter by |
pipeline_id is provided, only contacts with an active
ticket whose current stage belongs to that pipeline are returned. You can combine
pipeline_id with stage_id to filter by both.Response Ordering
Contacts are returned ordered bylast_message_at in descending order (most recent first).
Cross-Channel Support
This endpoint returns contacts from all channels:| Platform | Description |
|---|---|
whatsapp | WhatsApp Business API |
web-whatsapp | WhatsApp Web (QR) |
instagram | Instagram Direct Messages |
webchat | Web chat widget |
sms | SMS messages |
messenger | Facebook Messenger |
tiktok | TikTok Direct Messages |
voice | Voice calls |
playground | Test/playground channel |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid days parameter (must be 1-365) |
| 401 | Unauthorized - Invalid or missing API key |
| 500 | Internal Server Error - Something went wrong |
Important Notes
- Days Range: Must be between 1 and 365 days
- Null Values: Some fields like
emailorphonemay be null - Performance: Response time increases with larger
daysvalues - All Channels: Unlike the deprecated WhatsApp-specific endpoint, this returns contacts from ALL channels
- Contact Count: No pagination - returns all contacts matching the criteria
- Stage Filtering: When
stage_idis provided, only contacts with an active ticket in that stage are returned - Pipeline Filtering: When
pipeline_idis provided, only contacts with an active ticket in a stage belonging to that pipeline are returned - Combined Filters:
days,stage_id, andpipeline_idcan be used together to narrow down results - Active Ticket: The
active_ticket_v2object contains the current ticketβsidandcurrent_stage_id
Performance Considerations
- Cache Results: Consider caching responses for frequently used
daysvalues - Large Datasets: For
daysvalues > 90, expect larger response sizes - Rate Limiting: Be mindful of rate limits when making frequent requests
Comparison with Deprecated Endpoint
| Feature | New Endpoint (This) | Deprecated Endpoint |
|---|---|---|
| Path | /api/public/contacts | /api/public/whatsapp/contact/contacts |
| Channels | All channels | WhatsApp only |
| Response | AI Contact objects | WhatsApp Contact objects |
| Ordering | By last_message_at DESC | Not specified |
| Future Support | β Active development | β Deprecated |
Related Endpoints
- GET /api/public/contact//info - Get detailed contact info
- POST /api/public/customer/upsert/info - Create or update contact
- POST /api/public/contact//update-metadata - Update contact metadata
Best Practices
1. Choose Appropriate Days Range
2. Handle Empty Results
3. Filter on Client Side
Headers
API key needed to authorize the request
Query Parameters
Filter contacts whose last message was within this many days (1-365)
1 <= x <= 36530
Return only contacts created strictly after this ISO 8601 timestamp. Use for syncing newly created contacts.
"2024-01-15T10:00:00.000Z"
Return only contacts updated strictly after this ISO 8601 timestamp. Use as a sync cursor to pull both new and modified contacts since the last poll.
"2024-01-15T10:00:00.000Z"
Maximum number of contacts to return (1-1000)
1 <= x <= 1000100
Number of contacts to skip, for pagination
x >= 00
Stage ID to filter contacts
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"123e4567-e89b-12d3-a456-426614174000"
Pipeline ID to filter contacts by their active ticket stage
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"123e4567-e89b-12d3-a456-426614174000"
The key of the custom field to filter by. Must be provided together with custom_field_value.
1"status"
The value to match for the custom field. Must be provided together with custom_field_key.
1"Active"
Specify "ticket" or "customer" to filter only by custom fields of that entity type. Only applies when custom_field_key and custom_field_value are provided.
ticket, customer Response
Contacts retrieved successfully.
"df980fc8-b6db-4820-bf22-2969482d106d"
"John Doe"
"+56912345678"
"john@example.com"
"whatsapp"
"2024-09-30T10:00:00.000Z"
"ATTENDED"
"2024-01-15T10:00:00.000Z"
"2024-01-16T09:30:00.000Z"
"123e4567-e89b-12d3-a456-426614174000"
"123e4567-e89b-12d3-a456-426614174000"
"123e4567-e89b-12d3-a456-426614174000"
false
true
