Skip to content

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.

Entity
Event
Description
CommandDeviceCommandEvent triggered when a device command is updated
ReservationReservationEvent triggered when a reservation is updated
ResourceResourceEvent triggered when a resource is updated
PricePriceUpdateEvent triggered when a rate price is updated
[WebSocketAddress]/ws/connector
  • WebSocketAddress - Base address for Mews WebSockets, depending on the Environment (Demo or Production).

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.

Cookie: ClientToken=E0D439EE522F44368DC78E1BFB03710C-D24FB11DBE31D4621C4817E028D9E1D; AccessToken=C66EF7B239D24632943D115EDE9CB810-EA00F8FD8294692C940F6B5A8F9453D

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.
{
"Events": [
{
"Type": "DeviceCommand",
"Id": "2391a3df-1c61-4131-b6f8-c85b4234adcb",
"State": "Pending"
},
{
"Type": "Reservation",
"Id": "bfee2c44-1f84-4326-a862-5289598f6e2d",
"State": "Processed",
"StartUtc": "2016-02-20T13:00:00Z",
"EndUtc": "2016-02-22T11:00:00Z"
},
{
"Type": "Resource",
"Id": "5ee074b1-6c86-48e8-915f-c7aa4702086f",
"State": "Dirty"
},
{
"Type": "PriceUpdate",
"Id": "bd75f159-f22a-4685-abdb-aac0008e2af3",
"StartUtc": "2019-09-07T22:00:00Z",
"EndUtc": "2019-09-07T22:00:00Z",
"RateId": "9c6c0556-42bb-409a-86ca-6ca430773b99",
"ResourceCategoryId": null
}
]
}
PropertyTypeContractDescription
Eventsarray of EventrequiredThe events that happened during the connection.

Depending on the event Type, it is one of the following:

If the integration is configured to handle commands for some devices, it will receive events whenever a command is created or updated.

PropertyTypeContractDescription
Typestring DeviceCommandrequiredType of the event.
IdstringrequiredUnique identifier of the Command.
Statestring Command staterequiredState of the command.

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.).

PropertyTypeContractDescription
Typestring ReservationrequiredType of the event.
IdstringrequiredUnique identifier of the reservation.
Statestring Reservation staterequiredState of the reservation.
StartUtcstringrequiredStart of the reservation (arrival) in UTC timezone in ISO 8601 format.
EndUtcstringrequiredEnd of the reservation (departure) in UTC timezone in ISO 8601 format.
AssignedResourceIdstringoptionalUnique identifier of the Resource assigned to the reservation.

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).

PropertyTypeContractDescription
Typestring ResourcerequiredType of the event.
IdstringrequiredUnique identifier of the Resource.
Statestring Resource staterequiredState of the resource.

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.

PropertyTypeContractDescription
Typestring PriceUpdaterequiredType of the event.
IdstringrequiredUnique identifier of the update event.
StartUtcstringoptionalStart of the price update interval in UTC timezone in ISO 8601 format.
EndUtcstringoptionalEnd of the price update interval in UTC timezone in ISO 8601 format.
RateIdstringoptionalUnique identifier of the Rate assigned to the update price event.
ResourceCategoryIdstringoptionalUnique identifier of the Resource category assigned to the update price event.