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) |
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) | Current pipeline stage |
blocked | boolean | Whether the contact is blocked |
is_chat_read | boolean | Whether the chat has been read by an agent |
Example Request
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. Activity Dashboard
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 |
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
email
orphone
may be null - Performance: Response time increases with larger
days
values - All Channels: Unlike the deprecated WhatsApp-specific endpoint, this returns contacts from ALL channels
- Contact Count: No pagination - returns all contacts matching the criteria
Performance Considerations
- Cache Results: Consider caching responses for frequently used
days
values - Large Datasets: For
days
values > 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
Number of days to filter contacts (1-365)
Required range:
1 <= x <= 365
Example:
30
Response
Contacts retrieved successfully.
Example:
"df980fc8-b6db-4820-bf22-2969482d106d"
Example:
"John Doe"
Example:
"+56912345678"
Example:
"john@example.com"
Example:
"whatsapp"
Example:
"2024-09-30T10:00:00.000Z"
Example:
"ATTENDED"
Example:
"2024-01-15T10:00:00.000Z"