Lead Create & Update API Guide  •  Version 3.00  •  Prepared by Mike Emery  •  24 February 2020

Leads can be posted into the system or updated through an HTTP post of XML data to a specific URL. Up to 100 requests can be submitted at once.

1. Introduction

1.1 XML Format

The expectation is for data to be wrapped in two hierarchical elements, Data and Lead. To submit multiple leads, repeat the last element (in this case Lead). XML data is therefore expected in the format:

<DATA>
  <LEAD>
    ...
  </LEAD>
</DATA>

Note

A common mistake when working with XML data is not encoding certain characters such as &amp;, &lt; and &gt; into their XML character entities. For example, within data being sent, the &amp; sign should be converted to the &amp;amp; character entity.

Search the internet for ‘XML Character Entities’ for more details.

1.2 Posting URL

The posting URL can be generated through the ‘Tools > Capture Leads’ page. If the service is accessed at the address domain.example.com, the posting URL would be:

https://domain.example.com/api/APILeadCreateUpdate.php

1.3 Testing

As with all lead submission methods, submitting a lead with first name flg and last name test will validate the request without entering a lead into the database, returning a lead ID of 000000 if successful.

1.4 Creating Leads

To create leads, an access key may be required. This depends on the lead group settings.

  • If the lead group allows leads to be captured through an iFrame and web form, no access key is required. This is set for each lead group in ‘Settings > Lead groups > Edit Group’, under ‘General Settings > General Preferences’. The setting is called ‘Allow capture leads through iFrame and web form’.
  • If the lead group does not allow leads to be captured through an iFrame and web form, an access key is required. Provide the key in a key element. Access keys can be created in ‘Settings > Access Keys’.

To create a new lead, make a request without an id element. The absence of this element tells the service that the request is to create a new lead.

Example create request (with access key)

<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
  <lead>
    <key>Yrg32FoiRdSriLYEbLrzSvFmurBGsPiz</key>
    <leadgroup>10</leadgroup>
    <site>20</site>
    <introducer>30</introducer>
    <reference>Lead123</reference>
    <source>Google</source>
    <medium>PPC</medium>
    <term>Loans</term>
    <cost>10.00</cost>
    <value>100.00</value>
    <title>Mr</title>
    <firstname>John</firstname>
    <lastname>Smith</lastname>
    <company>ABC Ltd.</company>
    <jobtitle>Manager</jobtitle>
    <phone1>0161 123 1234</phone1>
    <phone2>07912 123 456</phone2>
    <fax>0161 123 1235</fax>
    <email>john@abc.com</email>
    <address>1 High Street</address>
    <address2>This Village</address2>
    <towncity>This Town</towncity>
    <postcode>BB12 6EG</postcode>
    <dobday>01</dobday>
    <dobmonth>01</dobmonth>
    <dobyear>1990</dobyear>
    <contacttime>Anytime</contacttime>
    <data1>Ford</data1>
    <data2>Mondeo</data2>
    <data3>2005</data3>
    <data4>4000</data4>
  </lead>
</data>

If no access key is required, make a request without a key element.

1.5 Updating Leads

To update leads, an access key is required. Provide the key in a key element. Access keys can be created in ‘Settings > Access Keys’.

Most of the same values that can be sent in a create lead request can be used to update leads. Those fields marked with note 3 in section 2.1 cannot.

Example update request

<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
  <lead>
    <key>Yrg32FoiRdSriLYEbLrzSvFmurBGsPiz</key>
    <id>1001150</id>
    <data1>Ford</data1>
    <data2>Mondeo</data2>
    <data3>2005</data3>
    <data4>4000</data4>
  </lead>
</data>

2. Post Format

2.1 Post Data Elements

FieldTypeRequired1
Create
Required1
Update
SampleNotes
KeyStringYesYesYrg32FoiRdS…Obtained from ‘Access Keys’
IdIntegerYes1001150The lead ID to be updated
Leadgroup3IntegerYes10Provided by ‘Capture Leads’
Site3Integer20Provided by ‘Capture Leads’
Introducer3Integer30Provided by ‘Capture Leads’
Buyer6Integer40Preferred referral partner (see note 6)
Type2StringSecured LoanSets the lead type
User2StringJane SmithSets the assigned user
Status2StringNewSets the status
Ipaddress3String192.168.0.1Overrides detected IP address
ReferenceStringLead123Introducer’s lead reference
SourceStringGoogleMarketing source
MediumStringPPCMarketing medium
TermStringLoansMarketing term
CostDecimal10.00Cost of lead
ValueDecimal100.00Value of lead
TitleStringUserMrSee Title Values
FirstnameStringYesJohn
LastnameStringYesSmith
CompanyStringUserABC Ltd.
JobtitleStringUserManager
Phone14NumberUser0161 123 1234
Phone24NumberUser07912 123 456
Fax4NumberUser0161 123 1235
EmailStringUserjohn@abc.comMust be a valid email address
AddressStringUser1 High Street
Address2StringThis Area
Address3StringThis Village
TowncityStringUserThis Town
Postcode5StringUserBB12 6EG
DobString01/01/1990Overrides individual DOB fields
DobdayNumberUser01
DobmonthNumberUser01
DobyearNumberUser1990
ContacttimeStringUserAnytimeSee Contact Time Values
ContactphoneStringYesSee Contact Permission Values
ContactsmsStringYesSee Contact Permission Values
ContactemailStringYesSee Contact Permission Values
ContactmailStringYesSee Contact Permission Values
ContactfaxStringYesSee Contact Permission Values
Data1 – Data50VariesUserAnythingLead group data field value

Notes

  1. Fields marked User can be set as required within the lead group’s settings, so may be required. Fields marked Yes are always required.
  2. These are optional. If lead type is not specified, the lead type will be determined by lead type filters. If status is not specified, the first status with a ‘New’ conversion point will be set. If user is not specified, the lead will be unassigned.
  3. These fields cannot be submitted in an update request.
  4. Phone number validation level can be set within the lead group’s settings. Either only valid UK formatted phone numbers will be accepted, or any value. If the field is set to accept any input, all non-numeric and whitespace characters will be stripped out.
  5. Postcode validation level can be set within the lead group’s settings. Either only valid UK postcodes will be accepted, or any value.
  6. Specify a single preferred referral partner ID in buyer, or multiple preferred partner IDs in separate numbered fields such as buyer, buyer2, buyer3, … buyer10.

    If the lead is to be referred and the specified partner is eligible for the referral, the preferred referral partner will always be chosen. Likewise, if multiple preferred partners are specified, all of the partners will be preferred over others.

    The effect is similar to setting the partner’s lead type ‘selection priority’ higher than for other partners. Note that the partner must be eligible for the referral in the first place, otherwise the setting will have no effect.

2.2 Contact Time Values

Value
Anytime
Morning
Afternoon
Evening

2.3 Contact Permission Values

This value indicates whether permission has been obtained to make contact by phone, fax, email or mail.

ValueDescription
UnknownNot known
YesPermission obtained
NoDo not contact using this medium

3. Response Format

The server will respond with XML data containing a parent element Result, and within it a single Status element and one or more Item elements.

If the post is successful, a single Item element will enclose the new (or updated) lead ID. If unsuccessful, one or more item elements will contain the error(s) found.

3.1 Response Data Elements

FieldTypeSampleNotes
StatusBit0Returns 0 on success and 1 if there are errors
RecordInteger1The sequential record number (if submitting multiple requests in one post)
CodeInteger0Error code (see table below)
MessageStringOKResponse message
IdInteger1001150New/updated lead ID

3.2 Error Codes

CodeDescription
0No errors
1Validation error
2Declined as duplicate
3Declined as no lead type available (usually out of acceptance criteria)
4XML format error or no XML provided

4. Create Lead Example

4.1 Post Data

<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
  <lead>
    <key>Yrg32FoiRdSriLYEbLrzSvFmurBGsPiz</key>
    <leadgroup>10</leadgroup>
    <site>20</site>
    <introducer>30</introducer>
    <reference>Lead123</reference>
    <source>Google</source>
    <medium>PPC</medium>
    <term>Loans</term>
    <cost>10.00</cost>
    <value>100.00</value>
    <title>Mr</title>
    <firstname>John</firstname>
    <lastname>Smith</lastname>
    <company>ABC Ltd.</company>
    <jobtitle>Manager</jobtitle>
    <phone1>0161 123 1234</phone1>
    <phone2>07912 123 456</phone2>
    <fax>0161 123 1235</fax>
    <email>john@abc.com</email>
    <address>1 High Street</address>
    <address2>This Village</address2>
    <towncity>This Town</towncity>
    <postcode>BB12 6EG</postcode>
    <dobday>01</dobday>
    <dobmonth>01</dobmonth>
    <dobyear>1990</dobyear>
    <contacttime>Anytime</contacttime>
    <data1>Ford</data1>
    <data2>Mondeo</data2>
    <data3>2005</data3>
    <data4>4000</data4>
  </lead>
</data>

4.2 Response Data

<?xml version="1.0" encoding="ISO-8859-1"?>
<result>
  <status>0</status>
  <item>
    <record>1</record>
    <code>0</code>
    <message>OK</message>
    <id>1001150</id>
  </item>
</result>