Skip to main content

Messages

Retrieve messages for a specific conversation. Messages are returned in chronological order.

Endpoint

GET /v1/messages

Authentication

Requires a valid API key via the X-API-Key header.

Parameters

ParameterTypeRequiredDefaultDescription
conversationIdstringYes--The ID of the conversation to fetch messages for.
platformstringNoAuto-detectedFilter by platform. Supported values: instagram, line, facebook, whatsapp.
fromstringNo--ISO 8601 timestamp. Only return messages sent at or after this time.
tostringNo--ISO 8601 timestamp. Only return messages sent at or before this time.
limitnumberNo50Maximum number of messages to return. Max value: 100.

Request Example

curl

curl -X GET "https://api.convotic.com/v1/messages?conversationId=conv_abc123&limit=20" \
-H "X-API-Key: your-api-key-here"

With date range

curl -X GET "https://api.convotic.com/v1/messages?conversationId=conv_abc123&from=2026-03-01T00:00:00Z&to=2026-03-31T23:59:59Z&limit=50" \
-H "X-API-Key: your-api-key-here"

Response Example

{
"messages": [
{
"id": "msg_001",
"conversationId": "conv_abc123",
"platform": "instagram",
"direction": "inbound",
"sender": {
"id": "ct_abc123",
"name": "Somchai Prasert"
},
"content": {
"type": "text",
"text": "Hi, I'd like to ask about your product."
},
"timestamp": "2026-03-30T14:20:00Z"
},
{
"id": "msg_002",
"conversationId": "conv_abc123",
"platform": "instagram",
"direction": "outbound",
"sender": {
"id": "agent_01",
"name": "Support Bot"
},
"content": {
"type": "text",
"text": "Hello! Thank you for reaching out. Which product are you interested in?"
},
"timestamp": "2026-03-30T14:20:05Z"
},
{
"id": "msg_003",
"conversationId": "conv_abc123",
"platform": "instagram",
"direction": "inbound",
"sender": {
"id": "ct_abc123",
"name": "Somchai Prasert"
},
"content": {
"type": "image",
"url": "https://cdn.convotic.com/media/msg_003_img.jpg",
"caption": "This one"
},
"timestamp": "2026-03-30T14:21:30Z"
}
],
"conversationId": "conv_abc123",
"total": 3,
"limit": 20
}

Response Fields

FieldTypeDescription
messagesMessage[]Array of message objects in chronological order.
conversationIdstringThe conversation these messages belong to.
totalnumberTotal number of messages returned.
limitnumberThe limit value used for this request.

Message Object

FieldTypeDescription
idstringUnique message identifier.
conversationIdstringThe conversation this message belongs to.
platformstringThe messaging platform.
directionstring"inbound" (from contact) or "outbound" (from agent/bot).
senderobjectObject containing id and name of the sender.
contentobjectMessage content object. Contains type ("text", "image", "video", "file") and type-specific fields.
timestampstringISO 8601 timestamp of when the message was sent.

TypeScript Example

interface MessageSender {
id: string;
name: string;
}

interface MessageContent {
type: "text" | "image" | "video" | "file";
text?: string;
url?: string;
caption?: string;
}

interface Message {
id: string;
conversationId: string;
platform: string;
direction: "inbound" | "outbound";
sender: MessageSender;
content: MessageContent;
timestamp: string;
}

interface MessagesResponse {
messages: Message[];
conversationId: string;
total: number;
limit: number;
}

const params = new URLSearchParams({
conversationId: "conv_abc123",
limit: "20",
});

const response = await fetch(
`https://api.convotic.com/v1/messages?${params}`,
{
headers: {
"X-API-Key": "your-api-key-here",
},
}
);

const data: MessagesResponse = await response.json();
data.messages.forEach((msg) => {
const arrow = msg.direction === "inbound" ? "<<" : ">>";
console.log(`${arrow} [${msg.sender.name}] ${msg.content.text ?? msg.content.type}`);
});