Skip to main content

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

    instanceId stringrequired

    ID of the instance.

Query Parameters

    page Page

    Default value: 1

    (Optional) Page number in pagination.

    sort Sort

    Possible values: [desc, asc]

    Default value: desc

    (Optional) Sort the data in ascending or descending order.

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
    messageId Message ID
    keyId Kei ID
    keyFromMe Key From Me
    keyRemoteJid Key Remote Jid
    contentType Content Type
    source Source

    Possible values: [web, ios, android]

    web | ios | android

    createdAt object

    Format: SO 8601

    lessThanOrEqual date-time

    Less than or equal to...

    greaterThanOrEqual date-time

    Greater than or equal to...

    MessageStatus object
    status Status

    Possible values: [DELIVERY_ACK, PENDING, PLAYED, READ]

    dateTime object
    lessThanOrEqual date-time

    Less than or equal to...

    greaterThanOrEqual date-time

    Greater than or equal to...

Responses

The return will be a JSON containing up to 50 messages that match the search criteria, paginated according to the page parameter.

Schema
    instanceId stringrequired
    name stringrequired
    state stringrequired

    Default value: active | inactive

    connection stringrequired

    Default value: open | close | refused

    createdAt stringrequired
    deletedAt date-timerequired
    WhatsApp object
    whatsappId stringrequired
    remoteJid stringrequired
    pictureUrl stringrequired
    pushName stringrequired
    createdAt stringrequired
    Business object
    businessId stringrequired
    name stringrequired
    MessagesPage object
    totalRecords numberrequired
    totalPages numberrequired
    currentPage numberrequired
    records object[]required
  • Array [
  • messageId stringrequired
    keyId stringrequired
    keyFromMe booleanrequired
    keyRemoteJid stringrequired
    keyParticipant stringrequired
    pushName stringrequired
    contentType stringrequired
    isGroup booleanrequired
    content objectrequired
    source stringrequired
    messageTimestamp stringrequired
    createdAt date-timerequired
    deletedAt date-timerequired
    typeOfDeletion stringrequired

    Possible values: [everyone, forMe]

    MessageStatus object[]required
  • Array [
  • status stringrequired

    Possible values: [DELIVERY_ACK, PENDING, PLAYED, READ]

    dateTime date-timerequired
  • ]
  • ]
Loading...