home > support > API > Trigger Booking Webhook
Manually trigger a booking notification webhook on demand for a booking.
For use by Tour Operators only (not Marketplace Agents). If you modify a booking via the API you can use this method to notify your configured integrations of the change, allowing them to pull in the latest details.
Currently only the asynchronous modified_booking event can be triggered. The event must be enabled on at least one asynchronous webhook (it is inactive by default) whose channel and tour scope match the booking — TourCMS will queue a notification to each matching webhook and return the list of URLs notified.
The modified_booking event is not intended for cancellations, payments or redemptions, those have separate events already.
| Call | /api/booking/webhook/trigger |
| Formats | XML |
| Example | URL: /api/booking/webhook/trigger.xml POST data:
|
| Verb | POST |
The following fields should be posted as XML when calling the API, both are required.
| XML Node | Notes |
|---|---|
| booking_id | TourCMS ID for the booking to notify about. It can also be its UUID in case it has one. |
| event | The webhook event to trigger. Currently only modified_booking is accepted. |
PHP examples use the PHP Client Library with SimpleXML
object trigger_booking_webhook ( int $booking, string $event, int $channel )
// Set the channel ID
$channel = 3930;
// Which booking to notify about
$booking = 1234;
// The event to trigger
$event = "modified_booking";
// Call TourCMS API, triggering the webhook notification
$result = $tourcms->trigger_booking_webhook($booking, $event, $channel);
// Check the result, will be "OK" if the notification(s) were queued
if ($result->error == "OK") {
// Print out each webhook URL that was notified
foreach ($result->webhook_notifications->webhook_url as $url) {
echo $url . "\n";
}
} else {
// Some problem, e.g. NO_MATCHING_DATA / NO_MATCHING_EVENT / UNPROCESSABLE_EVENT
print $result->error_message;
}
https://www.example.com/webhook
NodeJS examples use the NodeJS Wrapper
TourCMS.triggerBookingWebhook({
channelId: 3930,
booking: {
booking_id: 1234,
event: "modified_booking"
},
callback: function(response) {
console.log(response.error);
}
});
OK
Looking for sample code in a different language? TourCMS and community provided API libraries
Implementing yourself? Check the REST info for this endpoint.
Enter your TourCMS API credentials below to call the Trigger Booking Webhook endpoint.
Take care, submitting this form will modify live data!
| XML Node | Notes |
|---|---|
| request | Confirmation of the request that you sent |
| error | OK if the notification(s) were queued, otherwise NOTOK (see error_message). |
| error_message | Only present when error is NOTOK. One of the error codes below. |
| webhook_notifications | Only present on success. Contains a webhook_url child node for each webhook endpoint URL queued to be notified. |
| error_message | Notes |
|---|---|
| NO_MATCHING_DATA | No booking was found for the supplied booking id / uuid on this channel. |
| NO_MATCHING_EVENT | The supplied event is not a recognised booking event. |
| UNPROCESSABLE_EVENT | The event exists but cannot be triggered on demand yet (currently only modified_booking can). |
| INSUFFICIENT_BOOKING_USER_PERMISSION | The API user does not have permission to edit this booking. |
<?xml version="1.0" encoding="UTF-8"?>
<response>
<request>POST /api/booking/webhook/trigger.xml</request>
<error>OK</error>
<webhook_notifications>
<webhook_url>https://www.example.com/webhook</webhook_url>
</webhook_notifications>
</response>