Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jihvijhojhviihogyuvi/whatsapp-api/llms.txt

Use this file to discover all available pages before exploring further.

The messages endpoints retrieve the most recent messages from a one-to-one WhatsApp chat identified by phone number. There are two ways to call the same underlying function: a GET variant that accepts query parameters (convenient for browser testing and curl), and a POST variant that accepts a JSON body (better suited for programmatic clients that already build JSON payloads). Both variants return an identical response shape.

GET Variant

Use query parameters to specify the target chat and the number of messages to fetch.

Endpoint

GET /api/messages?phone_number=15551234567&limit=10

Query Parameters

phone_number
string
required
The phone number of the contact whose chat you want to read. Must include the country code. Non-digit characters are stripped automatically, and the result must be 8–15 digits.
limit
integer
default:"10"
Maximum number of messages to return. Must be between 1 and 100. Messages are returned in chronological order (oldest first within the returned window).

Example Request

curl "http://127.0.0.1:8790/api/messages?phone_number=15551234567&limit=5"

POST Variant

Use a JSON request body — functionally identical to the GET variant.

Endpoint

POST /api/messages

Body Parameters

phone_number
string
required
The phone number of the contact whose chat you want to read. Must include the country code. Non-digit characters are stripped automatically.
limit
integer
default:"10"
Maximum number of messages to return. Must be between 1 and 100.

Example Request

curl -X POST http://127.0.0.1:8790/api/messages \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "15551234567",
    "limit": 5
  }'

Response Fields

ok
boolean
required
true on a successful response.
chat
object
required
A chat summary object for the conversation identified by phone_number. Has the same shape as the chat objects in GET /api/chats.
count
integer
required
Number of message objects returned in the messages array.
messages
array
required
An array of message summary objects from the chat, ordered chronologically (oldest first).

Example Response

{
  "ok": true,
  "chat": {
    "id": "15551234567@c.us",
    "name": "Alice",
    "is_group": false,
    "is_read_only": false,
    "unread_count": 0,
    "timestamp": 1717250585,
    "archived": false,
    "pinned": false,
    "muted": false,
    "last_message": {
      "id": "true_15551234567@c.us_3EB0C767D97B2C123456",
      "from": "15551234567@c.us",
      "to": "me@c.us",
      "author": null,
      "from_me": false,
      "type": "chat",
      "body": "Are you free tomorrow?",
      "timestamp": 1717250585,
      "has_media": false
    }
  },
  "count": 3,
  "messages": [
    {
      "id": "true_me@c.us_AA11BB22CC33DD44EE55",
      "from": "me@c.us",
      "to": "15551234567@c.us",
      "author": null,
      "from_me": true,
      "type": "chat",
      "body": "Hey Alice, just checking in!",
      "timestamp": 1717249200,
      "has_media": false
    },
    {
      "id": "true_15551234567@c.us_FF66GG77HH88II99JJ00",
      "from": "15551234567@c.us",
      "to": "me@c.us",
      "author": null,
      "from_me": false,
      "type": "image",
      "body": "Check out this photo",
      "timestamp": 1717250100,
      "has_media": true
    },
    {
      "id": "true_15551234567@c.us_3EB0C767D97B2C123456",
      "from": "15551234567@c.us",
      "to": "me@c.us",
      "author": null,
      "from_me": false,
      "type": "chat",
      "body": "Are you free tomorrow?",
      "timestamp": 1717250585,
      "has_media": false
    }
  ]
}

Build docs developers (and LLMs) love