home > support > API > Marketplace API > cancel booking

Cancel Booking

Cancel a booking


Notes

Tour operators can cancel any bookings made in their account, Marketplace Agents can cancel bookings they have made in any account they are connected to.
 
Excludes temporary bookings, just delete those or let them expire.
 
Generally speaking with the TourCMS API you will be looking for an error node containing the text OK to determine success, note PREVIOUSLY CANCELLED here would also indicate a booking as being cancelled.

REST info

Endpoint/c/booking/cancel
FormatsXML
ExampleURL: /c/booking/cancel.xml
 
POST data:
<?xml version="1.0"?>
<booking>
  <booking_id>12345</booking_id>
  <note>Optionally add a (staff-facing) note here</note>
</booking>
VerbPOST

Code samples

PHP examples use the PHP Client Library with SimpleXML

Description

object cancel_booking ( SimpleXMLElement $booking_data, int $channel )


Parameters

$booking_data
SimpleXmlElement containing the booking data (must include booking ID)
$channel
ID number for the channel the booking belongs to

Example

// Set the channel ID
$channel = 3930;

// Create a new SimpleXMLElement to hold the booking details
$booking = new SimpleXMLElement('<booking />');

// Must set the Booking ID on the XML, so TourCMS knows which to cancel
$booking->addChild('booking_id', '12345');

// Optionally add a note explaining why the booking is cancelled
$booking->addChild('note', 'Booking created accidentally');

// Call TourCMS API, cancelling the booking
$result = $tourcms->cancel_booking($booking, $channel);

// Check the result, will be "OK" if a booking was updated
if ($result->error == "OK") {
    // Print a success message
	print "Booking cancelled.";
} else if($result->error == "PREVIOUSLY CANCELLED" {
    // Print a different success message
	print "Booking has already been cancelled.";
} else {
	// Some  problem
	print "Unable to cancel booking (" . $result->error . ").";
}
Booking deleted.

C# examples use the .Net Client Library

Overload list

XmlDocument CancelBooking ( XmlDocument bookingData, int channelId )


Parameters

bookingId
TourCMS Id number for the booking to cancel
channelId
ID number for the channel the booking belongs to

Example

//  Set the ID for the channel this booking is made with
int bookingId = 12345;

// Create an XMLDocument to hold the booking details
XmlDocument bookingData = new XmlDocument();

// Create the XML Declaration, append it to XML document
XmlDeclaration dec = bookingData.CreateXmlDeclaration("1.0", null, null);
bookingData.AppendChild(dec);

// Create the root element, append it to the XML document
XmlElement root = bookingData.CreateElement("booking");
bookingData.AppendChild(root);

// Must set the Booking ID so TourCMS knows which booking to update
XmlElement bookingId = bookingData.CreateElement("booking_id");
bookingId.InnerText = "12345";
root.AppendChild(bookingId);

// Optionally add a note explaining the reason for cancellation
XmlElement req = bookingData.CreateElement("note");
req.InnerText = "Booking created accidentally";
root.AppendChild(req);

// Send the data to the TourCMS API, cancelling the Booking
XmlDocument doc = myTourCMS.CancelBooking(bookingData, channelId);

// Check the status
// Will be "OK" if the booking was cancelled
// "PREVIOUSLY CANCELLED" if it has been cancelled already
string status = doc.SelectSingleNode("//error").InnerText;

Console.WriteLine(status);
OK

VB examples use the .Net Client Library

Overload list

XmlDocument CancelBooking ( XmlDocument bookingData, Integer channelId )


Parameters

bookingId
TourCMS Id number for the booking to cancel
channelId
ID number for the channel the booking belongs to

Example


' Set the ID for the channel this booking is made with
Dim channelId As Integer = 3930

' Create an XMLDocument to hold the booking details
Dim bookingData As XmlDocument = new XmlDocument()

' Create the XML Declaration, append it to XML document
Dim dec As XmlDeclaration = bookingData.CreateXmlDeclaration("1.0", null, null)
bookingData.AppendChild(dec)

' Create the root element, append it to the XML document
Dim root As XmlElement = bookingData.CreateElement("booking")
bookingData.AppendChild(root)

' Must set the Booking ID so TourCMS knows which booking to cancel
Dim bookingId As XmlElement = bookingData.CreateElement("booking_id")
bookingId.InnerText = "12345"
root.AppendChild(bookingId)

' Optionally add a note
Dim req As XmlElement = bookingData.CreateElement("note")
req.InnerText = "Booking created accidentally"
root.AppendChild(req)

' Send the data to the TourCMS API, cancelling the Booking
Dim doc As XmlDocument = myTourCMS.CancelBooking(bookingIdData, channelId)

' Check the status
' Will be "OK" if the booking was updated
' "PREVIOUSLY CANCELLED" if it has been cancelled already
Dim status As String = doc.SelectSingleNode("//error").InnerText

Console.WriteLine(status)
OK

NodeJS examples use the NodeJS Wrapper


Example

TourCMS.cancelBooking({
  channelId: 3930,
  booking: {
    booking_id: 8451,
    note: "Booked accidentally"
  },
  callback: function(response) {
    console.log(response.error);
  }
});
OK

Looking for sample code in a different language? TourCMS and community provided API libraries

Post fields

The following fields can be posted as XML when calling the API, the booking_id is the only required field.

Post fields
XML NodeNotes
booking_id TourCMS ID for the booking to delete
note Optionally add a note explaining why the booking was cancelled
cancel_reasonIf not set, we will assume reason 22

1 - Cancelled by customer request, see notes
2 - Cancelled by customer request, booked another tour
3 - Cancelled by staff, see notes
4 - Cancelled by staff, boook another tour
5 - Cancelled by staff, payment not received
6 - Cancelled by staff, tour not reached min. numbers
7 - Cancelled by staff, booking made in error
8 - Cancelled by staff, capacity exceeded
9 - Cancelled by staff, operational reasons
10 - Cancelled by staff, booking reopened for editing
11 - Cancelled by staff, bad weather
20 - Cancelled by system, expired quotation
21 - Cancelled by system, expired provisional booking
22 - Cancelled by customer (via website)
23 - Cancelled by agent (via website)

Response fields

Response fields
XML NodeNotes
request Confirmation of the request that you sent
error Any error message returned, if there is no error this will just contain the text OK.

More information