POST /api.xro/1.0/contact
Saves a contact record for a particular Xero customer. If the contact record does not exist (based on either ContactID, ContactNumber or Name) then it’s created, otherwise it’s updated.
Request Parameters
| Parameter | Description |
| apiKey(Required) | Your partner API Key. |
| xeroKey(Required) | The Xero Customer Key generated by the Xero customer and provided to you to access their organisation data. |
Example
To save a contact perform the following HTTP request. This will perform an update because the ContactNumber already exists.
<Contact> <ContactNumber>C20081234</ContactNumber> <ContactStatus>ACTIVE</ContactStatus> <Name>Red House Reads</Name> <EmailAddress>accounts@redhousereads.co.nz</EmailAddress> <Addresses> <Address> <AddressType>STREET</AddressType> <AddressLine1></AddressLine1> <AddressLine2></AddressLine2> <AddressLine3></AddressLine3> <AddressLine4></AddressLine4> <City></City> <Region></Region> <PostalCode></PostalCode> <Country></Country> </Address> <Address> <AddressType>POBOX</AddressType> <AddressLine1>Lvl 1</AddressLine1> <AddressLine2>Herd St Building</AddressLine2> <AddressLine3>Herd St</AddressLine3> <AddressLine4>Wellington</AddressLine4> <City>Wellington</City> <Region>Wellington</Region> <PostalCode>6011</PostalCode> <Country>New Zealand</Country> </Address> </Addresses> <Phones> <Phone> <PhoneType>DDI</PhoneType> <PhoneNumber>1234567</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>DEFAULT</PhoneType> <PhoneNumber>1234567</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>MOBILE</PhoneType> <PhoneNumber>123123</PhoneNumber> <PhoneAreaCode>21</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>FAX</PhoneType> <PhoneNumber>1234568</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> </Phones> <SkypeUserName>echo123</SkypeUserName> <BankAccountDetails>123-456-789</BankAccountDetails> </Contact>
This will response with the following XML document with an OK status to show the contact was updated successfully.
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <ID>751ec648-919f-41bd-9fac-4068e27fece6</ID> <Status>OK</Status> <ProviderName>XeroTest</ProviderName> <DateTimeUTC>2008-12-02T21:09:24.654875Z</DateTimeUTC> <Contact> <ContactID>74141f5b-c409-4ddc-8f10-a2e6823c2b19</ContactID> <ContactNumber>C20081234</ContactNumber> <ContactStatus>ACTIVE</ContactStatus> <Name>Red House Reads</Name> <EmailAddress>accounts@redhousereads.co.nz</EmailAddress> <Addresses> <Address> <AddressType>STREET</AddressType> <AddressLine1></AddressLine1> <AddressLine2></AddressLine2> <AddressLine3></AddressLine3> <AddressLine4></AddressLine4> <City></City> <Region></Region> <PostalCode></PostalCode> <Country></Country> </Address> <Address> <AddressType>POBOX</AddressType> <AddressLine1>Lvl 1</AddressLine1> <AddressLine2>Herd St Building</AddressLine2> <AddressLine3>Herd St</AddressLine3> <AddressLine4>Wellington</AddressLine4> <City>Wellington</City> <Region>Wellington</Region> <PostalCode>6011</PostalCode> <Country>New Zealand</Country> </Address> </Addresses> <Phones> <Phone> <PhoneType>DEFAULT</PhoneType> <PhoneNumber>1234567</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>DDI</PhoneType> <PhoneNumber>1234567</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>FAX</PhoneType> <PhoneNumber>1234568</PhoneNumber> <PhoneAreaCode>4</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>MOBILE</PhoneType> <PhoneNumber>123123</PhoneNumber> <PhoneAreaCode>21</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> </Phones> <UpdatedDateUTC>2008-12-02T21:09:24.748625Z</UpdatedDateUTC> <SkypeUserName>echo123</SkypeUserName> <BankAccountDetails>123-456-789</BankAccountDetails> </Contact> </Response>
Request Body Schema
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Contact"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="ContactID" type="xs:string" /> <xs:element minOccurs="0" name="ContactNumber" type="xs:string" /> <xs:element name="Name" type="xs:string" /> <xs:element minOccurs="0" name="EmailAddress" type="xs:string" /> <xs:element name="Addresses"> <xs:complexType> <xs:sequence> <xs:element name="Address"> <xs:complexType> <xs:sequence> <xs:element name="AddressType" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine1" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine2" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine3" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine4" type="xs:string" /> <xs:element minOccurs="0" name="City" type="xs:string" /> <xs:element minOccurs="0" name="Region" type="xs:string" /> <xs:element minOccurs="0" name="PostalCode" type="xs:unsignedShort" /> <xs:element minOccurs="0" name="Country" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Phones"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Phone"> <xs:complexType> <xs:sequence> <xs:element name="PhoneType" type="xs:string" /> <xs:element minOccurs="0" name="PhoneNumber" type="xs:unsignedInt" /> <xs:element minOccurs="0" name="PhoneAreaCode" type="xs:unsignedByte" /> <xs:element minOccurs="0" name="PhoneCountryCode" type="xs:unsignedByte" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element minOccurs="0" name="BankAccountDetails" type="xs:string" /> <xs:element minOccurs="0" name="SkypeUserName" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Response Xml Schema
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Response"> <xs:complexType> <xs:sequence> <xs:element name="ID" type="xs:string" /> <xs:element name="Status" type="xs:string" /> <xs:element name="ProviderName" type="xs:string" /> <xs:element name="DateTimeUTC" type="xs:dateTime" /> <xs:element name="Contact"> <xs:complexType> <xs:sequence> <xs:element name="ContactID" type="xs:string" /> <xs:element minOccurs="0" name="ContactNumber" type="xs:string" /> <xs:element name="ContactStatus" type="xs:string" /> <xs:element name="Name" type="xs:string" /> <xs:element minOccurs="0" name="EmailAddress" type="xs:string" /> <xs:element name="Addresses"> <xs:complexType> <xs:sequence> <xs:element name="Address"> <xs:complexType> <xs:sequence> <xs:element name="AddressType" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine1" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine2" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine3" type="xs:string" /> <xs:element minOccurs="0" name="AddressLine4" type="xs:string" /> <xs:element minOccurs="0" name="City" type="xs:string" /> <xs:element minOccurs="0" name="Region" type="xs:string" /> <xs:element minOccurs="0" name="PostalCode" type="xs:string" /> <xs:element minOccurs="0" name="Country" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Phones"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Phone"> <xs:complexType> <xs:sequence> <xs:element name="PhoneType" type="xs:string" /> <xs:element minOccurs="0" name="PhoneNumber" type="xs:string" /> <xs:element minOccurs="0" name="PhoneAreaCode" type="xs:string" /> <xs:element minOccurs="0" name="PhoneCountryCode" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="DateTimeUTC" type="xs:dateTime" /> <xs:element minOccurs="0" name="BankAccountDetails" type="xs:string" /> <xs:element minOccurs="0" name="SkypeUserName" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>