Get Campaign Messages
Retrieve conversation messages for all contacts in a campaign. This endpoint returns the full conversation history between contacts and the AI agent.
Endpoint
GET /v1/campaigns/{campaign_id}/messages
Authentication
Path Parameters
Query Parameters
ISO 8601 timestamp to get messages after this time. Useful for polling new messages.Example: 2026-01-23T00:00:00Z
Maximum number of messages to return
Response
Whether the request was successful
Array of message objects sorted by timestamp (newest first)
Unique message identifier
"user" for contact messages, "agent" for AI responses
Conversation thread identifier (format: {phone_number}_{campaign_id})
Number of messages returned
Whether there are more messages available (exceeds limit)
Example Request
curl "https://partner.teli.ai/api/proxy/v1/campaigns/camp_abc123/messages?limit=50" \
-H "X-API-Key: YOUR_API_KEY"
Example Response
{
"success": true,
"messages": [
{
"message_id": "msg_456",
"phone_number": "+15551234567",
"from_number": "+15551234567",
"to_number": "+15559876543",
"message": "Yes! My credit score is around 730",
"sender_type": "user",
"timestamp": "2026-01-23T19:31:00Z",
"thread_id": "+15551234567_camp_abc123"
},
{
"message_id": "msg_455",
"phone_number": "+15551234567",
"from_number": "+15559876543",
"to_number": "+15551234567",
"message": "Hi John, interested in refinancing your mortgage?",
"sender_type": "agent",
"timestamp": "2026-01-23T19:30:00Z",
"thread_id": "+15551234567_camp_abc123"
}
],
"count": 2,
"has_more": false,
"powered_by": "Teli"
}
Polling for New Messages
To implement real-time updates, poll with the since parameter:
let lastTimestamp = null;
async function pollMessages(campaignId) {
const url = lastTimestamp
? `https://partner.teli.ai/api/proxy/v1/campaigns/${campaignId}/messages?since=${lastTimestamp}`
: `https://partner.teli.ai/api/proxy/v1/campaigns/${campaignId}/messages`;
const response = await fetch(url, {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
if (data.messages && data.messages.length > 0) {
lastTimestamp = data.messages[0].timestamp;
// Process new messages
displayMessages(data.messages);
}
}
// Poll every 5 seconds
setInterval(() => pollMessages('camp_abc123'), 5000);