Searching messages

Message queries enable you to search for messages by property or within a specified date range. These queries can be very intensive and slow, so you should only use the following endpoints when you missed or lost messages using the /messages/latest endpoint.

Querying messages workflow

To make best use of the message queries, you should:

  1. Set up a query to return a specific batch of messages.
    The endpoint returns a job id.
  2. Consult the status of the query with the job id to see whether it is ready to be retrieved.
  3. Retrieve the batch of messages with the same call once the status changed to ready.

Creating a message query to retrieve messages

GET
https://supply-xml.booking.com/messaging/messages/search

The GET /messages/search request enables you to create a query to retrieve specific messages.

Message queries expire after 48 hours

After a message query is ready, the job id expires after 48 hours. That means you must create a new message query if you want to retrieve those messages again.

Query parameters

At least one parameter required

If you create a query, you must use at least one query parameter. If you do not, you receive a 400 response.

The following table describes what elements you must add in the request path:

Element Description Type Required/Optional Notes
before Specifies the date and time until when you want to retrieve messages. string optional Follows the ISO 8601 standard in UTC: YYYY-MM-DDThh:mm:ss.mmmZ. Specified time is included.
after Specifies the date and time after which you want to retrieve messages. string optional Follows the ISO 8601 standard in UTC: YYYY-MM-DDThh:mm:ss.mmmZ. Specified time is included.
property_id Specifies the id of the property you want to retrieve messages for. string optional
order_by Indicates whether you want the messages order in ascending (oldest first) or descending (most recent first) order. string optional Possible values: asc or desc.

Response body example

The following is a successful response body example:

{
  "data": {
      "expires_at": "2021-01-01T14:52:38.860Z[GMT]",
      "ok": true,
      "job_id": "a934b220-4aae-11eb-83e9-8f4bc4c2528d"
  },
  "errors": [],
  "warnings": [],
  "meta": {
      "ruid": "UmFuZG9tSVYkc2RlIyh9YYX5KO46o0C5R5CiotKrM4awgb8DeWP40oDQG6OR6x4lvYqbLiGYUQHR5EgyMmTTT8xAnK2feAdc"
  }

Response body elements

The following table describes the response elements:

Element Description Type Notes
data Contains the response object. object
: ok Indicates whether the request was successfull. boolean
: job_id Specifies the id of the message query. string You need this id to first consult the status of the message query.
: expires_at Specifies when the query expires. string The query expires after 48 hours.

Retrieving the messages from message query

GET
https://supply-xml.booking.com/messaging/messages/search/result/{job_id}

The GET /messages/search/result/{job_id} request enables you to retrieve the batch of messages with the job id. If the query is not ready yet, you can retrieve the current status of the query.

Path parameters

The following table describes what elements you must add in the request path:

Element Description Type Required/Optional Notes
job_id Specifies the id of the message query you must use to retrieve the messages. integer required

Query parameters

The following table describes what elements you can add as a query:

Element Description Type Required/Optional Notes
page_id Specifies the page number. string optional

Response body example

The following is a successful response body example:

{
    "meta": {
        "ruid": "UmFuZG9tSVYkc2RlIyh9YYX5KO46o0C5MsJ+UGJLilY3muQRMKEPgu7NoSFx+Uy39DgbUTEhF8CRI9WRh3JjYaJlMlu/Aa6F"
    },
    "warnings": [],
    "data": {
        "ok": true,
        "messages": [
            {
                "timestamp": "2020-12-29T16:09:28.405Z",
                "conversation": {
                    "conversation_id": "267eef2d-43fe-5b94-afef-63de2ee4d6f8",
                    "conversation_reference": "2232015613",
                    "conversation_type": "reservation"
                },
                "sender": {
                    "participant_id": "9f6be5fd-b3a8-5691-9cf9-9ab6c6217327",
                    "metadata": {
                        "name": "hotel_6378711",
                        "participant_type": "hotel"
                    }
                },
                "content": "Hello world.",
                "attachment_ids": null,
                "message_id": "3a4d3850-49f0-11eb-b489-c5aef2b46d67",
                "message": {},
                "property_id": 6378711
            },
            {
                "message_id": "5af92c30-49f0-11eb-ac8d-531702a3f2f6",
                "attachment_ids": null,
                "message": {},
                "property_id": 6378711,
                "timestamp": "2020-12-29T16:10:23.219Z",
                "conversation": {
                    "conversation_id": "267eef2d-43fe-5b94-afef-63de2ee4d6f8",
                    "conversation_type": "reservation",
                    "conversation_reference": "2232015613"
                },
                "content": "Hello world.",
                "sender": {
                    "participant_id": "9f6be5fd-b3a8-5691-9cf9-9ab6c6217327",
                    "metadata": {
                        "participant_type": "hotel",
                        "name": "hotel_6378711"
                    }
                }
            }
        ]
    },
    "errors": []

Response body parameters

The following table describes the response elements:

Element Description Type Notes
data Contains the response data. object
: ok Indicates whether the request was successfull. string
: messages Contains the message elements. array
:: message_id Specifies the unique id of a message. string
:: content Specifies the content of the message. string
:: timestamp Specifies the time when the message was sent. string Follows the ISO 8601 standard in UTC: YYYY-MM-DDThh:mm:ss.mmmZ.
attachment_ids Contains the ids of the attachment. array
:: property_id Specifies the id of the property. string
:: sender Contains information on the participant that sent the message. object
::: participant_id Specifies the participant id of a participant. string
::: metadata Contains information of a participant. object
:::: participant_type Specifies the type of the participant. string
:::: name Specifies the name of the property. string
:: conversation Contains the conversation elements. array
::: conversation_id Specifies the unique id of a conversation. string
::: conversation_reference Specifies the unique id of the conversation type this conversation is referring to. integer For now the references are all reservation ids.
::: conversation_type Specifies the type of the conversation. string For now the only possible value is reservation.