WebSockets
WebSockets provides another way to communicate with Mews, for special use cases where polling using API Operations is too resource consuming, and event-driven Webhooks are not sufficiently real-time. A WebSocket is an open connection over which Mews can send event messages as the events occur. After you make a successful WebSocket connection to Mews, you will receive event messages according to the configuration of your integration in Mews Operations. For a comparative overview of Operations vs Webhooks vs WebSockets, see Ways to communicate.
Supported events
Entity | Event | Description |
Command |
| Event triggered when a device command is updated |
Reservation |
| Event triggered when a reservation is updated |
Resource |
| Event triggered when a resource is updated |
Price |
| Event triggered when a rate price is updated |
Endpoint URL
WebSocketAddress - Base address for Mews WebSockets, depending on the Environment (Demo or Production).
Authentication
Authentication is done using the same combination of ClientToken
and AccessToken
as used for standard API operations. These tokens must be sent as cookies together with the connection request. Most WebSocket client libraries support this. For more information about client tokens and access tokens, see Authentication.
Note: There can't be any spaces around
=
in the Cookie value as this would prevent successful WebSocket connection.
ClientToken - Unique token per integration which will be provided to you by Mews upon successful certification.
AccessToken - Unique token per enterprise. Can be provided to you by the enterprise admin.
Message body
Property | Type | Contract | Description |
---|---|---|---|
| array of Event | required | The events that happened during the connection. |
Event
Depending on the event Type
, it is one of the following:
Device Command event
If the integration is configured to handle commands for some devices, it will receive events whenever a command is created or updated.
Property | Type | Contract | Description |
---|---|---|---|
| string | required | Type of the event. |
| string | required | Unique identifier of the Command. |
| string Command state | required | State of the command. |
Reservation event
If the integration is configured to receive reservation updates, it will receive events whenever any change is made to a reservation (created, updated, canceled, etc.).
Property | Type | Contract | Description |
---|---|---|---|
| string | required | Type of the event. |
| string | required | Unique identifier of the reservation. |
| string Reservation state | required | State of the reservation. |
| string | required | Start of the reservation (arrival) in UTC timezone in ISO 8601 format. |
| string | required | End of the reservation (departure) in UTC timezone in ISO 8601 format. |
| string | optional | Unique identifier of the Resource assigned to the reservation. |
Resource event
If the integration is configured to receive resource updates, it will receive events whenever a change is made to a resource (created, renamed, state updated).
Property | Type | Contract | Description |
---|---|---|---|
| string | required | Type of the event. |
| string | required | Unique identifier of the Resource. |
| string Resource state | required | State of the resource. |
Price Update event
If the integration is configured to receive price updates, it will receive events whenever a rate price is created or updated. Events are related to base price updates, price adjustments and category adjustments.
Property | Type | Contract | Description |
---|---|---|---|
| string | required | Type of the event. |
| string | required | Unique identifier of the update event. |
| string | optional | Start of the price update interval in UTC timezone in ISO 8601 format. |
| string | optional | End of the price update interval in UTC timezone in ISO 8601 format. |
| string | optional | Unique identifier of the Rate assigned to the update price event. |
| string | optional | Unique identifier of the Resource category assigned to the update price event. |
Last updated