Skip to main content

List WhatsApp Conversations Programmatically

This endpoint will help you list the conversations you have on your 2Chat-connected WhatsApp number.

Getting all conversations

info

You will first need to get the UUID of the channel you want to pull conversations from. You can do that by using this endpoint.

Assuming WPN582e4db7-6391-4e58-b79e-1b92e93a8374 is the UUID of the target group:

https://api.p.2chat.io/open/whatsapp/conversations/WPN582e4db7-6391-4e58-b79e-1b92e93a8374?page_number=0.

This call will return the last or newest 10 conversations you have on that channel. If you would like to see older ones, you can paginate the results:

  • Page 1, from 10 to 20: https://api.p.2chat.io/open/whatsapp/conversations/WPN582e4db7-6391-4e58-b79e-1b92e93a8374?page_number=1.
  • Page 2, from 20 to 30: https://api.p.2chat.io/open/whatsapp/conversations/WPN582e4db7-6391-4e58-b79e-1b92e93a8374?page_number=2.
  • Page n: ...
tip

You can also search for conversations with certain number using the phone_number query parameter. You can specify between 3 and 20 digits of the phone number to perform the search.

For example: https://api.p.2chat.io/open/whatsapp/conversations/WPN582e4db7-6391-4e58-b79e-1b92e93a8374?phone_number=123456 will return conversations with phone numbers that contain the value 123456.

Invocation

curl --location --request GET 'https://api.p.2chat.io/open/whatsapp/conversations/WPN582e4db7-6391-4e58-b79e-1b92e93a8374?page_number=0' \
--header 'X-User-API-Key: your_api_key_here' \
--data-raw ''

Response

{
"success": true,
"page_number": 0,
"total": 2,
"search_term": "123",
"sessions": [
{
"session_key": "WW-WPN582e4db7-6391-4e58-b79e-1b92e93a8374-1713123456@c.us",
"friendly_name": "John",
"region_name": "Miamiy, FL",
"iso_country_code": "US",
"device": "android",
"channel_uuid": "WPN582e4db7-6391-4e58-b79e-1b92e93a8374",
"phone_number": "+1713123456",
"timezone": "America/Miami",
"profile_pic_url": "https://2chat-user-data-dev.s3.amazonaws.com/pp/contacts/...jpeg",
"is_group_chat": false,
"last_user_message_sent_at": "2025-01-07T13:27:55Z",
"last_activity_at": "2025-01-07T13:27:55Z",
"created_at": "2024-06-26T20:54:21Z",
"contact": {
"id": 1342,
"uuid": "CONe6226cd2-cb09-491f-9854-8a9b0626406a",
"first_name": "John",
"last_name": "Forta",
"channel_uuid": null,
"profile_pic_url": null
}
},
{
"session_key": "WW-WPN582e4db7-6391-4e58-b79e-1b92e93a8374-5255512345678@c.us",
"friendly_name": null,
"region_name": "Mexico City, FD",
"iso_country_code": "MX",
"device": null,
"channel_uuid": "WPN582e4db7-6391-4e58-b79e-1b92e93a8374",
"phone_number": "+5255512345678",
"timezone": "America/Mexico_City",
"profile_pic_url": null,
"is_group_chat": false,
"last_user_message_sent_at": null,
"last_activity_at": "2024-10-22T01:37:23Z",
"created_at": "2024-10-22T01:06:36Z"
}
]
}