home > support > API > Marketplace API > update customer

Update Customer

Update the details on a customer record


Notes

Tour Operators can update any customer, travel agents with permission level 3 (full data access to own data) can update customer records that they originally created, except for custom fields or the customer_username, customer_password fields.

Useful for updating the contact details on a customer created as part of a temporary or even committed booking, perhaps if customer details weren't known at the time.

Could also be used by Tour Operators perhaps combine with the Customer Login Search to create a way for customers to log in and update their contact / marketing preferences.

REST info

Call/c/customer/update
FormatsXML
ExampleURL: /c/customer/update.xml
 
POST data:
<?xml version="1.0"?>
<customer>
	<customer_id>12345</customer_id>
	<email>joe.bloggs@example.com</email>
</customer>
VerbPOST

Code samples

PHP examples use the PHP Client Library with SimpleXML

Description

object update_customer ( SimpleXmlElement $customer_data, int $channel )


Parameters

$customer_data
SimpleXmlElement containing the customer data (must inc their ID)
$channel
ID number for the channel the customer belongs to

Example

// Set the channel ID
$channel = 3;

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

// Must set the Customer ID on the XML, so TourCMS knows
// who to update
$customer->addChild('customer_id', '12345');

// Provide a new email address, perhaps they filled in a form
// saying they had changed it
$customer->addChild('email', 'joe.bloggs@example.com');

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

// Check the result, will be "OK" if a customer was updated
switch ($result->error) {
    case "OK":
        // Print a success message
        print "Thanks, your 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 correct address already!";
        break;
    default:
        // Some other problem (could check error to see what)
        print "Sorry, unable to update your details at this time";
        break;
}
Thanks, your details have been updated

C# examples use the .Net Client Library

Overload list

XmlDocument UpdateCustomer (XmlDocument customerDetails, int channelId)


Parameters

customerDetails
XmlDocument containing the Customer data to update (see table below)
channelId
ID number for the channel the Customer belongs to

Example

// ID for the channel (supplier) the customer belongs to
int channelId = 3;

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

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

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

// Must set the Customer ID on the XML, so TourCMS knows
// who to update
XmlElement customerId = customer.CreateElement("customer_id");
customerId.InnerText = "12345";
root.AppendChild(customerId);

// Provide a new email address, perhaps they filled in a form
// saying they had changed it
XmlElement email = customer.CreateElement("email");
email.InnerText = "joe.bloggs@example.com";
root.AppendChild(email);

// Call the API
XmlDocument doc = myTourCMS.UpdateCustomer(customer, channelId);

// Get the response status, will be "OK" if TourCMS updated the customer
// or "NO DATA CHANGED" if the new data matched the existing data
string status = doc.SelectSingleNode("//error").InnerText;
Console.WriteLine(status);
OK

VB examples use the .Net Client Library

Overload list

XmlDocument UpdateCustomer (XmlDocument customerDetails, Integer channelId)


Parameters

customerDetails
XmlDocument containing the Customer data to update (see table below)
channelId
ID number for the channel the Customer belongs to

Example

' ID for the channel (supplier) the customer belongs to
Dim channelId As Integer = 3;

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

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

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

' Must set the Customer ID on the XML, so TourCMS knows who to update
Dim customerId As XmlElement = customer.CreateElement("customer_id")
customerId.InnerText = "12345"
root.AppendChild(customerId)

' Provide a new email address, perhaps they filled in a form
' saying they had changed it
Dim email As XmlElement = customer.CreateElement("email")
email.InnerText = "joe.bloggs@example.com"
root.AppendChild(email)

' Call the API
Dim doc As XmlDocument = myTourCMS.UpdateCustomer(customer, channelId)

' Get the response status, will be "OK" if TourCMS updated the customer
' or "NO DATA CHANGED" if the new data matched the existing data
Dim status As String = doc.SelectSingleNode("//error").InnerText
Console.WriteLine(status)
OK

NodeJS examples use the NodeJS Wrapper


Example

// Change the first name for customer 12345 on Channel 3930 to "Joseph"
TourCMS.updateCustomer({
  channelId: 3930,
  customer: {
    customer_id: 12345,
    firstname: "Joseph"
  },
  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 customer_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
customer

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

XML NodeNotes
customer_idTourCMS Internal ID number for the Customer record, this must be provided
perm_emailWhether the customer should be opted in to email marketing or not.
 
1 = Yes
0 = No
Blank / not set = Take account default settings
titleCustomer title e.g. Mr, Mrs etc
firstnameFirst name
surnameSurname
emailEmail address
tel_homeTel home / evening
faxFax number
tel_workTel work / day
tel_mobileTel mobile
tel_smsTel sms
contact_noteContact note (e.g. don't call before 8pm)
addressAddress (can be multi-line)
cityCity
countyCounty / State
postcodePostcode / Zipcode
country2 digit country code (uppercase). Here's a HTML snippet containing all countries in a select box
middlenameMiddle name (or initial)
nationality2 digit country code (uppercase). Here's a HTML snippet containing all countries in a select box
genderThe customers gender.
 
Leave blank if gender is unknown, otherwise supply one of the following digits:
m = Male
f = Female
x = Indeterminate
dobDate of Birth (YYYY-MM-DD)
agecatAge category - 1 digit code (i-Infant, c-Child, a-Adult, s-Senior).
Alternatively if you know the customers DOB then pass that instead and TourCMS will calculate the agecat automatically.
pass_numPassport number
pass_issuePassport place of issue
pass_issue_datePassport issue date (YYYY-MM-DD)
pass_expiry_datePassport expiry date (YYYY-MM-DD)
wherehearWhere did the customer hear about us (doesn't have to be pre-configured)
dietDietary requirements
medicalMedical conditions
nok_nameEmergency contact name
nok_relationshipEmergency contact relationship
nok_telEmergency contact telephone number
nok_contactEmergency contact other note (can be multi-line)
If calling API as the tour operator (not an agent)
customer_usernameUnique configurable identifier for the user, pass this in to change the username the customer uses to log into booking engines / other services. Could be the users email address but doesn't have to be.
customer_passwordMust be 6 to 12 characters in length. Can contain uppercase letters, lowercase letters and numbers.
 
If an empty password node is submitted to the API then login for the customer will be disabled. Passwords in an incorrect format will be silently ignored and the original password will remain (can use Show Customer to check whether password was updated).
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. InsideLeg. 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. 32 inches

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

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

XML NodeNotes
customer_idID number for the Customer record
channel_idChannel ID
account_idAccount ID

More information