Skip to main content

Get a WABA Conversation Programmatically

Agent Skill

Automate this endpoint with an AI agent using the 2chat-whatsapp-waba skill:

npx skills add 2ChatCo/agent-skills -s 2chat-whatsapp-waba

This endpoint returns the conversation between one of your WhatsApp Business API numbers and a single contact, newest first.

It is the one to reach for when you know which contact you care about: it is cheaper than reading the whole number and it reads an indexed path, so paging deep into a long conversation stays fast.

Endpoint

GET https://api.p.2chat.io/open/waba/messages/{from_number}/{to_number}

Authentication

Include your API key in the X-User-API-Key header. Learn more about authentication.

Parameters

ParameterInRequiredDescription
from_numberpathYesYour WABA number in E.164 format. The leading + is optional (e.g. +15550001111)
to_numberpathYesThe contact's number in E.164 format. The leading + is optional (e.g. +5215512345432)
page_numberqueryNoZero-based page, paging back in time. Defaults to 0
results_per_pagequeryNoMessages per page, between 1 and 200. Defaults to 50

Paging

page_number is zero-based and results_per_page decides how many messages each one holds, newest first:

  • Page 0, the newest: https://api.p.2chat.io/open/waba/messages/+15550001111/+5215512345432
  • Page 1, the 50 before those: https://api.p.2chat.io/open/waba/messages/+15550001111/+5215512345432?page_number=1
  • 200 at a time: https://api.p.2chat.io/open/waba/messages/+15550001111/+5215512345432?results_per_page=200&page_number=1
Stop on has_more, not on a short page

Keep paging while has_more is true.

A contact you have never exchanged messages with is not an error: you get success: true with an empty messages list.

Invocation

curl --location --request GET 'https://api.p.2chat.io/open/waba/messages/+15550001111/+5215512345432?page_number=0' \
--header 'X-User-API-Key: your_api_key_here'

Response

Success (HTTP 200 OK)

{
"success": true,
"page_number": 0,
"results_per_page": 50,
"has_more": false,
"messages": [
{
"id": "MSGaf1fa3a1-0d8d-4aa5-b117-f9425b651485",
"uuid": "MSGaf1fa3a1-0d8d-4aa5-b117-f9425b651485",
"session_key": "WA-WAN95841312-b54d-46e3-b0bc-6414f4a5296b-5215512345432",
"message": {
"text": "hi, do you have this in stock?"
},
"created_at": "2026-09-20T14:03:11",
"remote_phone_number": "+5215512345432",
"channel_phone_number": "+15550001111",
"sent_by": "user"
}
]
}

page_number, results_per_page and has_more behave exactly as in Get Messages by Phone Number, and so do the message fields.

Error

{
"error": true,
"error_message": "WhatsApp Profile setup not found"
}
HTTPWhen
400from_number or to_number is not a valid number in international format, or the page starts past the 50000-message limit
404Your account has no WABA number matching from_number
422page_number is negative, or results_per_page is outside 1–200
429Too many concurrent reads of the same conversation. Retry shortly