Get WABA Messages 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 messages you sent and received on one of your WhatsApp Business API numbers, newest first, across every conversation that number holds.
To read a single conversation instead, use Get Conversation Messages.
Endpoint
GET https://api.p.2chat.io/open/waba/messages/{from_number}
Authentication
Include your API key in the X-User-API-Key header. Learn more about authentication.
Parameters
| Parameter | In | Required | Description |
|---|---|---|---|
from_number | path | Yes | Your WABA number in E.164 format. The leading + is optional, so you do not have to escape it in the URL (e.g. +15550001111 or 15550001111) |
page_number | query | No | Zero-based page, paging back in time. Defaults to 0 |
results_per_page | query | No | Messages 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:
- Page 0, the newest:
https://api.p.2chat.io/open/waba/messages/+15550001111 - Page 1, the 50 before those:
https://api.p.2chat.io/open/waba/messages/+15550001111?page_number=1 - 200 at a time:
https://api.p.2chat.io/open/waba/messages/+15550001111?results_per_page=200&page_number=1
has_more, not on a short pageKeep paging while has_more is true, and stop when it turns false.
Invocation
- cURL
- Python
- JavaScript
- PHP
curl --location --request GET 'https://api.p.2chat.io/open/waba/messages/+15550001111?page_number=0' \
--header 'X-User-API-Key: your_api_key_here'
import requests
url = "https://api.p.2chat.io/open/waba/messages/+15550001111"
headers = {
"X-User-API-Key": "your_api_key_here"
}
response = requests.get(url, params={"page_number": 0, "results_per_page": 50}, headers=headers)
print(response.json())
const axios = require('axios');
const response = await axios.get('https://api.p.2chat.io/open/waba/messages/+15550001111', {
params: { page_number: 0, results_per_page: 50 },
headers: {
'X-User-API-Key': 'your_api_key_here'
}
});
console.log(response.data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/waba/messages/+15550001111?page_number=0',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
Success (HTTP 200 OK)
{
"success": true,
"page_number": 0,
"results_per_page": 50,
"has_more": true,
"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"
},
{
"id": "MSG8c39a0a9-01cf-46c9-ab46-3c0fb0477e99",
"uuid": "MSG8c39a0a9-01cf-46c9-ab46-3c0fb0477e99",
"session_key": "WA-WAN95841312-b54d-46e3-b0bc-6414f4a5296b-5215512345432",
"message": {
"text": "yes, let me confirm the size for you"
},
"created_at": "2026-09-20T14:05:48",
"remote_phone_number": "+5215512345432",
"channel_phone_number": "+15550001111",
"sent_by": "agent"
}
]
}
| Field | Description |
|---|---|
success | true when the request was successful |
page_number | The page you asked for, echoed back |
results_per_page | The page size in effect, echoed back |
has_more | true when older messages exist past this page. Keep paging while it is true |
messages | The page of messages, newest first |
messages[].id | The unique identifier of the message |
messages[].uuid | Same as id |
messages[].session_key | The conversation the message belongs to. WABA session keys look like WA-{channel uuid}-{digits}, with no @c.us suffix |
messages[].message.text | The text content of the message, when present |
messages[].message.media.url | The 2Chat-hosted media file URL, when the message carries media |
messages[].message.media.type | The type of media |
messages[].message.media.mime_type | The MIME type of the media |
messages[].created_at | When the message was sent, UTC |
messages[].remote_phone_number | The contact's phone number |
messages[].channel_phone_number | Your WABA number the message went through |
messages[].sent_by | Who sent it: user (the contact), agent, or api |
Error
{
"error": true,
"error_message": "WhatsApp Profile setup not found"
}
| HTTP | When |
|---|---|
400 | from_number is not a valid number in international format, or the page starts past the 50000-message limit |
404 | Your account has no WABA number matching from_number |
422 | page_number is negative, or results_per_page is outside 1–200 |
429 | Too many concurrent reads of the same number. Retry shortly |