History
Read the chats and messages the gateway has stored: the last HISTORY_SYNC_DAYS days imported when the number was linked, plus everything sent and received since. It's the same data the inbox shows.
List chats
http
GET /session/:session/chats| Query | |
|---|---|
q | Search by name, phone number or JID. |
filter | all (default; archived chats left out), unread, groups or archived. |
limit | Chats per page, 1 to 500. Default 100. |
before | The next_before of the previous page. |
json
{
"data": [
{
"jid": "447700900123@s.whatsapp.net",
"name": "Emma Wilson",
"phone": "+447700900123",
"isGroup": false,
"unread": 0,
"lastMessage": "Afternoon is perfect, thanks!",
"lastMessageFromMe": false,
"lastMessageAt": 1764584460,
"archived": false,
"pinned": true
}
],
"next_before": "1764500000:14165550142@s.whatsapp.net"
}Most recent first; pinned chats come first on the first page. next_before is null on the last page.
List messages
http
GET /session/:session/chats/:chat/messages:chat is a phone number (447700900123) or a JID (120363012345678901@g.us for groups).
| Query | |
|---|---|
limit | Messages per page, 1 to 500. Default 50. |
before | The next_before of the previous page, to go further back. |
A page holds the newest messages, ordered oldest to newest. next_before is the ID of the oldest message on the page, or null when there's nothing older.
json
{
"data": [
{
"id": "3EB0C4F1A2",
"fromMe": false,
"sender": { "jid": "447700900123@s.whatsapp.net", "name": "Emma Wilson" },
"type": "text",
"text": "Afternoon is perfect, thanks!",
"media": null,
"status": null,
"reactions": { "me": "❤️" },
"edited": false,
"timestamp": 1764584460,
"quoted": { "id": "3EB0POLL01", "fromMe": true, "sender": null, "preview": "📊 Poll · Which delivery slot works best?" },
"location": null,
"contacts": null,
"poll": null
}
],
"next_before": "3EB0C4F1A2"
}| Field | |
|---|---|
sender | Who sent it, null for your own messages. |
type | text, image, video, audio, document, sticker, location, contact, pollCreation, revoked (deleted), … |
media | { kind, mime, name, url } for media messages. Download it from url (see below). |
status | Your messages only: pending, server, delivered, read, played or error. |
reactions | Emoji per person. me is your own reaction. |
quoted | The message this one replies to. |
location | { latitude, longitude, name, address } |
contacts | [{ name, phones }] for contact cards. |
poll | { name, multiple, options: [{ name, votes }] } |
Download media
http
GET /session/:session/chats/:chat/messages/:id/mediaReturns the file. It's fetched from WhatsApp on the first request and cached on your server. WhatsApp keeps media for a limited time; when it's gone the response is 410.