Aller au contenu principal

GET /contacts/:uuid/messages

List all messages belonging to the contact. Results are paginated and sorted by createdAt in descending order.

Optional Parameters​

ParameterTypeDescription
pageIntegerThe page of messages. If not specified it will default to page 1.
afterStringCursor for fetching the next page. Pass the next value from the previous response's meta field. When present, page is ignored.

Example Request​

curl -X GET "https://api.callbell.eu/v1/contacts/efd7d996470e463b89f079be6cf578ed/messages" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json"

Response​

ParameterTypeDescription
messagesMessages[]A list of messages.
metaObjectPagination metadata.

Meta Object​

ParameterTypeDescription
pageIntegerCurrent page number. Only present when using offset pagination (?page=N).
pagesIntegerTotal number of pages. Only present when using offset pagination (?page=N).
nextStringCursor to pass as ?after= to retrieve the next page of results. null when there are no more pages.

Example Response​

response.json
{
"messages": [
{
"text": "Hello there how can I help you?",
"createdAt": "2023-12-12T10:56:36Z",
"uuid": "cf839626ac7949879b88bcffd41d34fe",
"status": "sent",
"channel": "whatsapp",
"from": "391234567890",
"to": "390987654321"
},
{
"text": "Conversation was assigned to John Doe",
"createdAt": "2023-12-12T10:56:35Z",
"status": "note",
"channel": "whatsapp",
"from": "390987654321",
"to": "390987654321"
},
{
"text": "Hello there 👋",
"createdAt": "2023-12-12T10:53:32Z",
"status": "received",
"channel": "whatsapp",
"from": "390987654321",
"to": "390987654321"
}
],
"meta": {
"page": 1,
"pages": 5,
"next": "eyJ0cyI6MTcwMTM3NTIxNjAwMCwiaWQiOjQyfQ"
}
}

Cursor Pagination​

To iterate through all messages efficiently, use the after parameter with the meta.next value from each response. When meta.next is null, you have reached the last page.

response.json
{
"messages": [...],
"meta": {
"next": "eyJ0cyI6MTcwMTM3NTIxNjAwMCwiaWQiOjQyfQ"
}
}