home > support > API > Marketplace API > update booking

Update Booking

Update some of the information on an existing booking


Notes

Tour Operators can update quite a few fields, Marketplace Agents can only update agent_ref. Agents should request any further changes by using the Add note to booking API

Functionality to add or remove booking components is available via separate APIs.

REST info

Endpoint/c/booking/update
FormatsXML
ExampleURL: /c/booking/update.xml
 
POST data:
<?xml version="1.0"?>
<booking>
	<booking_id>12345</booking_id>
	<customer_special_request>
		Please can we have a ground floor room
	</customer_special_request>
</booking>
VerbPOST

Code samples

PHP examples use the PHP Client Library with SimpleXML

Description

object update_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 = 3;

// 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 update
$booking->addChild('booking_id', '12345');

// Provide their special request information
$booking->addChild('customer_special_request', 'Please can we have a ground floor room');

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

// Check the result, will be "OK" if a booking was updated
switch ($result->error) {
    case "OK":
		// Print a success message
	    print "Thanks, your booking details have been updated.";
	    break;
	case "NO DATA CHANGED":
		// Nothing was changed, old data matched new data
	    print "Thanks, it looks like we have your request already!";
	    break;
	default:
		// Some other problem (could check error to see what)
	    print "Sorry, unable to update your booking details at this time.";
	    break;
}
Thanks, your booking details have been updated.

C# examples use the .Net Client Library

Overload list

XmlDocument UpdateBooking ( XmlDocument bookingData, int channelId )


Parameters

bookingData
XmlDocument containing the booking data (must include booking ID). See "Post fields" table below for full list.
channelId
ID number for the channel the booking belongs to

Example


// Set the ID for the channel this booking is made with
int channelId = 3;

 // 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);

// Now set any details that need updating
// Here we'll update the "Special request"
XmlElement req = bookingData.CreateElement("customer_special_request");
req.InnerText = "Please can we have a ground floor room";
root.AppendChild(req);

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

// Check the status
// Will be "OK" if the booking was updated
// "NO DATA CHANGED" if the new data matched the old, etc
string status = doc.SelectSingleNode("//error").InnerText;

Console.WriteLine(status);
OK

VB examples use the .Net Client Library

Overload list

XmlDocument UpdateBooking ( XmlDocument bookingData, Integer channelId )


Parameters

bookingData
XmlDocument containing the booking data (must include booking ID). See "Post fields" table below for full list.
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 = 3

' 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 update
Dim bookingId As XmlElement = bookingData.CreateElement("booking_id")
bookingId.InnerText = "12345"
root.AppendChild(bookingId)

' Now set any details that need updating
' Here we'll update the "Special request"
Dim req As XmlElement = bookingData.CreateElement("customer_special_request")
req.InnerText = "Please can we have a ground floor room"
root.AppendChild(req)

' Send the data to the TourCMS API, updating the Booking
Dim doc As XmlDocument = myTourCMS.UpdateBooking(bookingData, channelId)

' Check the status
' Will be "OK" if the booking was updated
' "NO DATA CHANGED" if the new data matched the old, etc
Dim status As String = doc.SelectSingleNode("//error").InnerText

Console.WriteLine(status)
OK

NodeJS examples use the NodeJS Wrapper


Example


// This example sets the Customer Special Request field on the booking
TourCMS.updateBooking({
  channelId: 3930,
  booking: {
    booking_id: 1234,
    customer_special_request: "Please can we have a ground floor room"
  },
  callback: function(response) {
    console.log(response.error);
  }
});
OK

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

Querystring parameters

There are no querystring parameters.

Post fields

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

Any fields not present in the XML will not be updated, to clear a field you will need to add it to the XML but leave it's contents blank.

Post fields
XML NodeNotes
booking

The root XML element, can contain any of the following child nodes.

XML NodeNotes
booking_idTourCMS Internal ID number for the Booking, this must be provided
agent_refTravel agent reference. Could be a booking reference for the booking in the agent's own system. May be blank
If API called by Tour Operator (not Marketplace Agent)
booking_name_customSet a custom name for the booking, e.g. Mr & Mrs Bloggs Anniversary, set to blank to indicate that the auto calculated booking name should be used (default)
final_checkOptionally set to 1 to indicate that the booking has had the "final check" completed by staff, 0 if it hasn't.
customer_special_requestUpdate the customer "Special Request" field on the booking
important_noteUpdate the "Pinned note" on the booking
workflow_noteUpdate the "Workflow note" on the booking
customers

TourCMS stores booking specific information about each customer, the customers node allows you to detail any changes. Currently this can be used to update travel insurance details.
 
To update an actual customer record itself (name, contact details etc) you should instead use the Update Customer API method.

XML NodeNotes
customer

Include a customer node for each Customer that you wish to update, containing the following:

XML NodeNotes
customer_idThe ID number for the Customer, they must already be on the booking
insurance_numberThe customers insurance number
insurance_noteThe customers insurance note
custom_fields

If any custom fields are configured then they can be added in a custom_fields node containing the following child nodes:

XML NodeNotes
field

There should be a field node for each custom field containing the following two child nodes:

XML NodeNotes
nameCustom field name E.g. PickupPoint. This can be found in the setup for the custom field inside TourCMS, it is labelled Token (RTF and email templates) and will be a string containing no spaces
valueValue for the custom field E.g. Hilton Hotel

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. If no data was updated (perhaps because the supplied data was the same as the existing data this will contain the text NO DATA CHANGED.
booking

If the booking was found there will be a booking node containing the following child nodes.

XML NodeNotes
booking_idID number for the Booking
channel_idChannel ID
account_idAccount ID

More information