💬 Chats
Chats methods.

Features
Here’s the list of features that are available by 🏭 Engines:
💬 Chats - API
| API | WEBJS | GOWS | NOWEB |
|---|---|---|---|
Get all chatsGET /api/{session}/chats | ✔️ | ✔️ | ✔️¹ |
Get chats overviewGET /api/{session}/chats/overview | ✔️ | ✔️ | ✔️¹ |
Get chat pictureGET /api/{session}/chats/{chatId}/picture | ✔️ | ✔️ | ✔️¹ |
Unread chatPOST /api/{session}/chats/{chatId}/unread | ✔️ | ✔️ | ✔️¹ |
Archive chatPOST /api/{session}/chats/{chatId}/archive | ✔️ | ✔️¹ | |
Unarchive chatPOST /api/{session}/chats/{chatId}/unarchive | ✔️ | ✔️¹ | |
Delete chatDELETE /api/{session}/chats/{chatId} | ✔️ | ||
Read messagesPOST /api/{session}/chats/{chatId}/messages/read | ✔️ | ✔️ | ✔️¹ |
Get messagesGET /api/{session}/chats/{chatId}/messages | ✔️ | ✔️ | ✔️¹ |
Get message by idGET /api/{session}/chats/{chatId}/messages/{messageId} | ✔️ | ✔️ | ✔️¹ |
Pin messagePOST /api/{session}/chats/{chatId}/messages/{messageId}/pin | ✔️ | ✔️ | |
Unpin messagePOST /api/{session}/chats/{chatId}/messages/{messageId}/unpin | ✔️ | ✔️ | |
Edit messagePUT /api/{session}/chats/{chatId}/messages/{messageId} | ✔️ | ✔️ | |
Delete messageDELETE /api/{session}/chats/{chatId}/messages/{messageId} | ✔️ | ✔️ | |
Delete all messagesDELETE /api/{session}/chats/{chatId}/messages | ✔️ |
- NOWEB - you need to Enable Store to get chats, contacts and messages
If you see the feature is not available in the above list, please create a feature request or leave “+1” comment on the existing one.
💬 Chats - Events
| Events | WEBJS | NOWEB | GOWS |
|---|---|---|---|
chat.archive | ✔️ |
API
Parameters in path that you can find in below endpoints:
{session}- use the session name for Whatsapp instance that you created withPOST /api/sessionsendpoint{chatId}- chat id in format123123123123@[c.us|g.us],c.usfor direct chats andg.usfor groups.
Get all chats
Get all chats
GET /api/{session}/chatsChats Pagination
If you see timeout or the request takes too long - consider using limit parameter to get chats in smaller chunks
GET /api/{session}/chats?limit=100&offset=0&sortBy=messageTimestamp&sortOrder=desclimit=100- limit the number of chats to returnoffset=0- skip the number of chats from the startsortBy={field}- sort by fieldsortBy=messageTimestamp- sort by last message timestampsortBy=id- sort by chat idsortBy=name- sort by chat name
sortOrder=desc|asc- sort orderdesc- descending order (New first, A-Z)asc- ascending order (Old first, Z-A)
Get chats overview
Get chats “overview” - the API that almost all Chat UI client needs!
GET /api/{session}/chats/overview?limit=20&offset=0Query Parameters:
limit=100- limit the number of chats to returnoffset=0- skip the number of chats from the startids=11111&ids=9999@c.us- optional, filter result by chat id or phone number
Use POST request if you have a lot of chats (>400) in ids filter
POST /api/{session}/chats/overview{
"pagination": {
"limit": 20,
"offset": 0
},
"filter": {
"ids": ["111111@c.us"]
}
}Response contains the main info you need to show in the chat list:
id- chat idname- chat name (if any)picture- chat picture (if any)lastMessage- last message in the chat (if any)._chat- the structure depends on engine you’re using
⚠️ lastMessage doesn’t have media attachments, you need to get message by id to get media attachments.
[
{
"id": "12312l123@c.us",
"name": "John Doe",
"picture": "https://example.com/picture.jpg",
"lastMessage": {
"id": "true_11111111111@c.us_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"timestamp": 1667561485,
"from": "11111111111@c.us",
"fromMe": true,
"to": "11111111111@c.us",
"body": "Hi there!",
...
},
"_chat": {
...
}
}
]Get chat picture
Get chat picture (avatar, profile picture, group image) by chat id
GET /api/{session}/chats/{chatId}/picture[?refresh=True]Query
refresh=True- force refresh the picture. By default, we cache it 24 hours. Do not frequently refresh the picture to avoidrate-overlimiterror.
{
"url": "https://example.com/picture.jpg"
}urlcan benullif there’s no picture for the chat
Archive chat
Use the method to archive chat
POST /api/{session}/chats/{chatId}/archiveUnarchive chat
Use the method to unarchive chat
POST /api/{session}/chats/{chatId}/unarchiveUnread chat
Mark chat as unread
POST /api/{session}/chats/{chatId}/unreadDelete chat
Use the method to delete chat
DELETE /api/{session}/chats/{chatId}Read messages
You can mark all unread messages in the chat as read (double blue checkmark) using one query:
It’ll find all unread messages in the chat and mark them as read.
POST /api/{SESSION}/chats/{chatId}/messages/read{}{
"ids": [
"false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA",
"true_99999999999@c.us_AAAAAAAAAAAAAAAAAAAA"
]
}ids- list of message ids that were marked as read
👉 NOWEB: Please make sure to 🏭 Enable NOWEB Store before using this API!
Optionally, you can control how many messages you need to read:
{
"messages": 30,
"days": 7
}messages: 30- how many messages you need to read- defaults is
30for direct chats and100for groups
- defaults is
days: 7- how many days you need to read- default is
7
- default is
For more granular control, you can use the POST /api/sendSeen API.
Get messages
Get 10 messages from the chat
GET /api/{session}/chats/{chatId}/messages?limit=10Available parameters:
downloadMedia=true- download media files (images, files) or notchatId=123@c.us- chatId, phone numberchatId=all- get messages from all chats (works on NOWEB engine only)
limit=100- limit the number of chats to returnoffset=0- skip the number of chats from the startfilter.timestamp.lte=1727745026- filter messages by timestamp less than or equal to1727745026filter.timestamp.gte=1727745026- filter messages by timestamp greater than or equal to1727745026filter.fromMe=false- filter messages from me (by default, shows all messages)filter.ack=DEVICE- filter messages by ackERROR, ack: -1- error occurredPENDING, ack: 0- message is pendingSERVER, ack: 1- message was sent to serverDEVICE, ack: 2- message was sent to the deviceREAD, ack: 3- recipient read messagePLAYED, ack: 4- recipient played the message
Get 10 messages from the chat, skip downloading media (images, files)
GET /api/{session}/chats/{chatId}/messages?limit=10&downloadMedia=false[
{
"id": "false_123123@c.us_AAAAAA",
"timestamp": 1727745026,
"from": "123123@c.us",
"fromMe": false,
"body": "I'm good!",
"hasMedia": false,
"ack": 3,
"ackName": "READ",
"replyTo": null,
"_data": {
... // Raw Engine Data
}
}
]Get 10 messages from 1727745026 timestamp, not from me
GET /api/{session}/chats/{chatId}/messages?limit=10&filter.timestamp.gte=1727745026&filter.fromMe=false👉 If you have more messages - you can set offset flag
(increase it always for limit amount, even if you get less messages)
GET /api/{session}/chats/{chatId}/messages?limit=10&offset=10&filter.timestamp.gte=1727745026&filter.fromMe=falseGet message by id
Get message by id
GET /api/{session}/chats/{chatId}/messages/{messageId}?downloadMedia=true{
"id": "false_123123@c.us_AAAAAA",
"timestamp": 1727745026,
"from": "123123@c.us",
"fromMe": false,
"body": "I'm good!",
"hasMedia": false,
"ack": 3,
"ackName": "READ",
"replyTo": null,
"_data": {
... // Raw Engine Data
}
}chatId- in format123123123@c.usmessageId- must be in format{true|false}_213213@c.us_AAAAAAA)downloadMedia- download media files (images, files) or not
Pin message
POST /api/{session}/chats/{chatId}/messages/{messageId}/pin{
"duration": 86400
}- 24 hours -
duration=86400 - 7 days -
duration=604800 - 30 days -
duration=2592000
{
"success": true
}Unpin message
POST /api/{session}/chats/{chatId}/messages/{messageId}/unpin{
"success": true
}Edit message
You can edit text messages or “caption” in media messages.
PUT /api/{session}/chats/{chatId}/messages/{messageId}👉 Remember to escape @ in chatId and messageId with %40.
So if you want to edit true_123@c.us_AAA message in 123@c.us chat you need to send request to:
PUT /api/{session}/chats/123%40c.us/messages/true_123%40c.us_AAA{
"text": "Hello, world!"
}Delete message
You can delete messages from the chat.
DELETE /api/{session}/chats/{chatId}/messages/{messageId}👉 Remember to escape @ in chatId and messageId with %40.
So if you want to delete true_123@c.us_AAA message in 123@c.us chat you need to send request to:
DELETE /api/{session}/chats/123%40c.us/messages/true_123%40c.us_AAADelete all messages
Use the method to clear all messages from the chat
DELETE /api/{session}/chats/{chatId}/messages Events
Read more about 🔄 Events.
chat.archive
The chat.archive event is triggered when a chat is archived or unarchived.
{
"event": "chat.archive",
"session": "default",
"payload": {
"id": "123123123@c.us",
"timestamp": 1667561485,
"archived": true <== or false
},
...
}