Skip to main content

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

ParameterInRequiredDescription
from_numberpathYesYour 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_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:

  • 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
Stop on has_more, not on a short page

Keep paging while has_more is true, and stop when it turns false.

Invocation

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'

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"
}
]
}
FieldDescription
successtrue when the request was successful
page_numberThe page you asked for, echoed back
results_per_pageThe page size in effect, echoed back
has_moretrue when older messages exist past this page. Keep paging while it is true
messagesThe page of messages, newest first
messages[].idThe unique identifier of the message
messages[].uuidSame as id
messages[].session_keyThe conversation the message belongs to. WABA session keys look like WA-{channel uuid}-{digits}, with no @c.us suffix
messages[].message.textThe text content of the message, when present
messages[].message.media.urlThe 2Chat-hosted media file URL, when the message carries media
messages[].message.media.typeThe type of media
messages[].message.media.mime_typeThe MIME type of the media
messages[].created_atWhen the message was sent, UTC
messages[].remote_phone_numberThe contact's phone number
messages[].channel_phone_numberYour WABA number the message went through
messages[].sent_byWho sent it: user (the contact), agent, or api

Error

{
"error": true,
"error_message": "WhatsApp Profile setup not found"
}
HTTPWhen
400from_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 number. Retry shortly