Search Messages
POST/api/v2/instance/:instanceId/chat/search/messages
This endpoint allows you to perform detailed searches for messages within a specific instance, based on various criteria, including message attributes and creation dates associated with an instance, with paging limited to 50 messages per reply.
Request
Path Parameters
ID of the instance.
Query Parameters
Default value: 1
(Optional) Page number in pagination.
Possible values: [desc
, asc
]
Default value: desc
(Optional) Sort the data in ascending or descending order.
- application/json
Body
Search Parameters:
The request body must contain a JSON object specifying both the search criteria for retrieving messages and pagination options for controlling the size and order of the returned data set.
messageId: (Optional) A unique identifier assigned to each message. Use this attribute if you wish to find a specific message.
keyId: (Optional) The ID associated with the cryptographic key used for encrypting or securing the message. Useful for narrowing down messages with a particular security profile.
keyFromMe: (Optional) A Boolean value that, when set to "true", filters messages sent by the current user. Set to "false" to search for messages received by the current user.
keyRemoteJid: (Optional) The unique identifier of the remote sender of the message. Use this to search for messages coming from a specific sender.
contentType: (Optional) Specifies the format of the message's content. Options include "text," "image," etc. Useful for filtering messages by type of content.
source: (Optional) Identifies the originating platform or application of the message. For example, messages could come from "web," "mobile," or "API."
createdAt:
- lessThanOrEqual: (Optional) Filters messages that were created on or before a specific date and time. The date-time string should be in ISO 8601 format.
- greaterThanOrEqual: (Optional) Filters messages that were created on or after a specific date and time. The date-time string should be in ISO 8601 format.
MessageStatus:
- status: (Optional) Represents the delivery status of the message. Options could include "sent," "received," and "read". Useful for tracking the lifecycle of messages.
- dateTime:
- lessThanOrEqual: (Optional) Narrows down messages with a status time on or before a specified date and time. The date-time string should be in ISO 8601 format.
- greaterThanOrEqual: (Optional) Narrows down messages with a status time on or after a specified date and time. The date-time string should be in ISO 8601 format.
search object
Possible values: [web
, ios
, android
]
web | ios | android
createdAt object
Format: SO 8601
Less than or equal to...
Greater than or equal to...
MessageStatus object
Possible values: [DELIVERY_ACK
, PENDING
, PLAYED
, READ
]
dateTime object
Less than or equal to...
Greater than or equal to...
Responses
- 200
- 400
- 401
The return will be a JSON containing up to 50 messages that match the search criteria, paginated according to the page parameter.
- application/json
- Schema
- Example (from schema)
Schema
- Array [
- Array [
- ]
- ]
Default value: active | inactive
Default value: open | close | refused
WhatsApp object
Business object
MessagesPage object
records object[]required
Possible values: [everyone
, forMe
]
MessageStatus object[]required
Possible values: [DELIVERY_ACK
, PENDING
, PLAYED
, READ
]
{
"instanceId": "string",
"name": "string",
"state": "active | inactive",
"connection": "open | close | refused",
"createdAt": "string",
"deletedAt": "2024-04-14T14:11:05.704Z",
"WhatsApp": {
"whatsappId": "string",
"remoteJid": "string",
"pictureUrl": "string",
"pushName": "string",
"createdAt": "string"
},
"Business": {
"businessId": "string",
"name": "string"
},
"MessagesPage": {
"totalRecords": 0,
"totalPages": 0,
"currentPage": 0,
"records": [
{
"messageId": "string",
"keyId": "string",
"keyFromMe": true,
"keyRemoteJid": "string",
"keyParticipant": "string",
"pushName": "string",
"contentType": "string",
"isGroup": true,
"content": {},
"source": "string",
"messageTimestamp": "string",
"createdAt": "2024-04-14T14:11:05.704Z",
"deletedAt": "2024-04-14T14:11:05.704Z",
"typeOfDeletion": "everyone",
"MessageStatus": [
{
"status": "DELIVERY_ACK",
"dateTime": "2024-04-14T14:11:05.704Z"
}
]
}
]
}
}
BadRequestException
- application/json
- Schema
- Example (from schema)
Schema
Default value: string,[object Object]
{
"message": [
"string"
],
"error": "string",
"statusCode": 0
}
UnauthorizedException
- application/json
- Schema
- Example (from schema)
Schema
Default value: string,[object Object]
{
"message": [
"string"
],
"error": "string",
"statusCode": 0
}