home > support > API > webhooks > Booking Notification
Called when one of several events happens on a booking (see "Triggers" below). Useful if you wish to:
One of the following events, related to the Flag notifications staff receive:
* "New" booking notifications are also triggered when an existing booking changes status, e.g. a booking changing from "Provisional" to "Confirmed" would trigger the new_confirmed_web / _staff event.
Generally, the three primary events you should code for are: new_confirmed_web, new_confirmed_staff, cancelled
Configure your URL in Configuration & Setup > Webhooks and TourCMS will immediately begin calling it when any of the above trigger.
TourCMS appends query string parameters to your URL containing basic booking information (see table below), further details could then be obtained by calling the Show Booking API method.
The query string parameters may be extended in the future without warning.
Key | Notes |
---|---|
event | Which of the Triggers caused the hook to fire |
account_id | TourCMS Account ID |
account_name | Name of the TourCMS Account |
channel_id | TourCMS Channel ID |
booking_id | TourCMS ID for the Booking (unique per account, not over the entire TourCMS system) |
Assuming you configure TourCMS with the following URL:
https://www.example.com/notify
TourCMS will call the following URL when a newly confirmed booking 1234 is made via the web on channel 3930 in account 4069 (testoperator):
https://www.example.com/notify?event=new_confirmed_web&account_id=4069&account_name=testoperator&channel_id=3930&booking_id=1234
The following sample PHP code shows grabs the TourCMS Booking ID and Channel ID from the query string (payload):
$booking_id = (int)$_GET['booking_id'];
$channel_id = (int)$_GET['channel_id'];
These could then be passed to the Show Booking API to get full details of the booking:
$result = $tourcms->show_booking($booking_id, $channel_id);
print_r($result);
Don't forget to ensure your code returns a 200 status response, that's the default in most cases unless there is an error. If you aren't sure you can check the status you are currently returning by entering a test URL in httpstatus.io.
TourCMS will include an X-Request-Id header in the request when sending you the webhook. The value of this header will be a random semi-unique value (currently a UUID4). If you are able to log this header it may help debugging or tracing specific requests.
TourCMS looks for a 200 status code response, within 30 seconds of your code commencing.
If we do NOT receive this status code, the webhook will be called again until we do, or until 14 days of constant attempts have passed
n/a currently.
In the future TourCMS may allow adding a message to the booking audit trail. If you wish to future proof yourself for this, ensure you return a 200 status code on success and you may write out a message in JSON now, the format would be:
{
"text": "Your message goes here"
}