TABLE OF CONTENTS [Document Version - 2.0]




Cheat Sheet


Web Methods


It is important to note that these methods require the use of an API token set in a cookie. Please refer to the Authentication section



Bulk Loading of Leads

Method FunctionURLMethodVersion
Import a CSV file(s)ImportCsvFilesPOST multi-part form2.6.0.1



Individual Lead Management Methods

These are RESTful requests formatted in the style of

Entity/Id/action

OR

Entity/Id?param1=x&param2=y


Method FunctionURLParamsMethodVersion
Deactivate a LeadDeactivateLeadByPhone/{phoneNumber}?Scope={scope}&listID={listId}DELETE2.6.0.1
Deactivate a LeadDeactivateLeadByRefId/{referenceId}?Scope={scope}&listID={listId}DELETE2.8.0
Deactivate a LeadDeactivateLeadId/leadIdDELETE2.6.0.1
Add a New LeadAddLeadPost RequestPOST2.8.5
Bring Lead BackReactivateLeadByPhone/{phoneNumber}?listID=listId}&reactivateDnc={reactivateDnc}POST2.8.0
Bring Lead BackReactivateLeadByLeadId/{leadId}&reactivateDnc={reactivateDnc}POST2.8.0
Bring Lead BackReactivateLeadByLeadByRefId/{referenceId}?listID={listId}&reactivateDnc={reactivateDnc}POST2.8.0
Move/Update LeadMoveLeadByRefId{phoneNumber}?newListID={newListId}&oldListID={oldListId}&resetAttempts={resetAttempts}&updateFinal={updateFinal}&finalCode={finalCode}POST2.8.5



Full Process

  1. Authenticate and generate an API token.
  2. Call relevant API requests.
  3. Process return result.


Notes

  • If you require secondary table information (scripting information), please utilise the Bulk Upload method and not "AddLead".
  • The bulk loader does not require you to write a CSV file to disk, only that you stream your leads to the server.
  • You need to have a phone number when adding a lead.
  • If you use hot leads or otherwise have leads you would like to push as high priority, you can enable this via the IsHighPriority property on the LeadPhone object. This will prioritise the lead to be called above all others.
  • The maximum allowed request size is 51200000 bytes, or 51.2MB. Please consider this when sending large CSV files with the Bulk Import method. A request with too large a payload will return a HTTP 413 status code. 


What is a RESTful API?

A RESTful API is an API that communicates over Hypertext Transfer Protocol (HTTP) to retrieve data and to send data to remote servers using the same HTTP Verbs as the Web.


See 'https://en.wikipedia.org/wiki/Representational_state_transfer'


Back to Contents


Usage


This API allows the remote management of lead data within the MaxContact platform. The API makes it possible to insert and update leads either singly or in bulk by loading CSV, XML or JSON-based lead data files.



Common API Parameters


The following is a list of some common parameters that are used by a number of the API methods, along with details of what each parameter represents.

  • Lead ID – This is the unique ID for a lead once loaded into the system.
  • List ID – When leads are imported into the system, they are grouped together into lists. This is the unique ID of a particular list as recorded in the database.
  • Reference ID – An optional external reference number (e.g. a customer ID from an external CRM system, etc.) that can be supplied when leads are imported into the system and can be used as an alternate way of identifying particular leads.



Lead Activation and Deactivation Parameters


The following is a list of parameters that can be supplied to a number of the API methods that are used to activate and deactivate leads.

  • List ID – When activating or deactivating leads, an optional list ID parameter value can be supplied to restrict the set of leads that are activated/deactivated to just ones in the specified list.
  • Reactivate DNC -When reactivating leads, this optional Boolean parameter can be used to control whether leads that have been previously given a final code of ‘DNC’ (‘Do Not Call’) are reactivated or not. The default value is false, so if no value is supplied for this parameter, then leads with a final code of ‘DNC’ will not be reactivated.
  • Result Code – When deactivating leads, this optional string parameter, of up to 10 characters in length, can be used to provide additional details about the reason for deactivation. If no value is supplied, then a default result code (such as ‘API-Remove’) is applied to the lead and lead phones.
  • Scope – When deactivating leads, the scope parameter can be used to restrict the set of leads that are affected by the deactivation. Four different values can be supplied for the scope parameter (see appendix for full list); however, if no scope is specified, then the default value of ‘0 – All’ is used, which instructs the API to deactivate all of the leads that match the other search criteria.
  • Update History – When deactivating leads, this parameter instructs the API to update the result code of the last entry in the history table for each of the deactivated leads. The default value for this parameter is false.



Important Notes


  • The API methods require the use of an API token in the header of the request. Please check the section on authentication.
  • The bulk loader does not require you to write a CSV file to disk, only that you stream your leads to the server
  • A phone number is required to import a lead.
  • API imports, which are high priority, need to be set at the Import API Mapping configuration page or within the request to import the lead
  • The maximum allowed request size is 51200000 bytes, or 51.2MB. Please consider this when sending large CSV files with the bulk import method. A request with too large a payload will return an HTTP 413 status code.


Back to Contents


Authentication


An authentication token is required to access this API. A token can be requested from the token service using the Token API.



Tokens API


All API methods require a security token to use the system. This token is stored in the HTTP cookie to allow multiple API calls from one authentication request.


A token is requested by authenticating with a user and password combination. The Token service API will return a token on success.


Token URL

https://[CUSTOMER].maxcontact.com/webservices/services/apitoken/login/{login}


Password

The password needs to be sent in the authorisation header of the request; the password needs to be converted to Base64 with ASCII encoding to get the bytes[] from the password string.


Steps

  1. Make a request to the token URI.
  2. Store the token key for any subsequent requests.
  3. Make a request to the Lead Management Service.


Recommendations

  • It is recommended that you keep track of the Token Key and its expiry, as making a request every time can slow down the import process.
  • Login should be plain text.


When a successful API call is made to the API Token service, it will return a JSON/XML object. A token key must be passed to each API endpoint along with the request.


The TokenKey property is the API key you should use for the remainder of the session. You can use the ExpiryDate property to see when this will expire.


Back to Contents


Responses


By default, the API will return an XML response, but Accept and Content-Type headers with values of application/json can be supplied with requests, and this will result in the API returning JSON-formatted responses.


ImportDataResult

Most methods return an ImportDataResult object. The value of the “Errors” property will be a different type dependent on the method used.


{
Success: bool,
Errors: object containing additional information about any errors that were
encountered,
ImmediateRejectCount: integer,
ImportIDs: array of integer
}



Entities

API Lead Status

Returned by the Get Lead Info By Reference Id method, this object contains details of a lead. 


{
LeadID: int64, // Unique id of the lead
ListID: int, // Unique id of the list the lead belongs to
ReferenceID: string, // Optional external reference for the lead
Name: string, // Forename
Name2: string, // Surname
OtherInfo: string, // Extra info to be displayed to the agent
QueuedForCall: boolean, // Is the system about to dial the lead
FinalCodeID: int, // See appendix for list of final codes
TotalAttempts: int, // Number of times the lead has been dialled
LastCallDate: datetime, // Date and time of the last call
LastAgentID: int, // User Id of the agent that made the last call
ImportDate: datetime, // Date and time this lead was imported
Supplier: int, // Unique id of the supplier of this lead
LeadPhones: array of APILeadPhoneStatus entities
}


API Lead Phone Status

Returned by the Get Lead Info By Reference Id method, this object contains details of a lead phone.

{
LeadPhoneID: int64, // Unique Id of the lead phone
PhoneNumber: string, // Phone number or contact details
PhoneTypeID: int, // Type of phone number (e.g. work, home)
CanCall: boolean, // Indicates whether this number can be called
NextCallDate: datetime, // Date and time of the next call
Attempts: int, // Number of times the number has been dialled
FinalCodeID: int, // See appendix for list of final codes
TotalAttempts: int, // Total dial attempts this value does not reset
LastCallDate: datetime, // Date and time of the last call
LastResultCode: string, // Indicates the outcome of the last call
LastAgentID: int, // User Id of the agent that made the last call
ImportDate: datetime // Date and time this number was imported
}


Back to Contents


Methods


Deactivate Lead By Id

API to make a single lead ineligible for dialling based on a supplied lead ID.

DELETE
/webservices/services/leadmanagement/DeactivateLeadId/{leadId}
Params:
leadId: string
Returns:
ImportDataResult indicating success or failure

Notes

  • The API updates the supplied lead to prevent it from being called, and it also deletes any existing callbacks that may have been scheduled for the lead.
  • When deactivating the lead, this API method applies a result code of 'KILLED' to the identified lead and associated phones.


Example:


https://(customer).maxcontact.com/webservices/services/LeadManagement/DeactivateLeadId/1 


Back to Contents


Deactivate Leads By Id

API to make multiple leads ineligible for dialling using a comma-delimited string of lead IDs.

DELETE
/webservices/services/leadmanagement/DeactivateLeadId/{leadIds}
Params:
leadIds: string
Returns:
ImportDataResult indicating success or failure

Notes

  • The API updates the supplied leads to prevent them from being called, and it also deletes any existing callbacks that may have been scheduled for those leads.
  • When deactivating the lead, this API method applies a result code of ‘KILLED’ to the identified leads and associated lead phones.


Back to Contents


Deactivate Leads By Phone Number

API to make lead(s) ineligible for dialling based on a supplied phone number.

DELETE
/webservices/services/leadmanagement/DeactivateLeadByPhone/{phoneNumber}
Params:
phoneNumber: string,
resultCode: string,
scope: integer,
listId: int,
updateHistory: boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The API uses the supplied phone number to identify one or more leads, and then it updates those leads (and any associated lead phone records) to prevent any of them from being dialled. It also deletes any existing callbacks that may have been scheduled for the deactivated leads.
  • Consult the Common Parameters section for details of the resultCode, scope, listId and updateHistory parameters.


Example:


https://(customer).maxcontact.com/webservices/services/LeadManagement/DeactivateLeadByPhone/07811223123?Scope=0&listID=123&ResultCode=TEST&UpdateHistory=false 



Param
Description*Default
PhoneNumberThe given phone to kill.FN/A
ScopeGiven a phone number, decide which lead to deactivate.
You can kill all leads, the oldest leads or certain time-based leads.

Please refer to Appendix 2 for further details.
T0 (All)
ListIdThe list to remove the duplicate from. If this is set to 0, it will apply to all lists.T0 (All)
ResultCodeThe result code you want to use when deactivating the lead.T"API-Removed"
UpdateHistoryGo and find the last entry in History and change the result code to that specified. TFalse

(* = optional)


Back to Contents


Deactivate Leads By Reference Id

API to make lead(s) ineligible for dialling based on a supplied reference ID value.

DELETE
/webservices/services/leadmanagement/DeactivateLeadByRefId/{referenceId}
Params:
referenceId: string,
resultCode: string,
scope: integer,
listId: int,
updateHistory: boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The method deletes any existing callbacks that may have been scheduled for the deactivated leads.
  • Consult the Common Parameters section for details of the resultCode, scope, listId and updateHistory parameters.


Example:


https://(customer).maxcontact.com/webservices/services/LeadManagement/DeactivateLeadsByRefId?Scope=0&listID=123&ResultCode=TEST&UpdateHistory=false  


Content-Disposition: form-data; name="referenceIds"


Content Body:


[“abc-123”,

“def-456”,

“ghi-789”]


Param
Description*Default
ReferenceId
The reference ID in the database as imported.FN/A
ScopeGiven a phone number, decide which lead to deactivate.
You can kill all leads, the oldest leads or certain time-based leads.

Please refer to Appendix 2 for further details.
T0 (All)
ListIdThe list to remove the duplicate from. If this is set to 0, it will apply to all lists.T0 (All)
ResultCodeThe result code you want to use when deactivating the lead.T"API-Removed"
UpdateHistoryGo and find the last entry in History and change the result code to that specified. TFalse

(* = optional)


Back to Contents


Deactivate Leads By Reference

API to make multiple leads ineligible for dialling based on a supplied list of reference IDs.

POST
/webservices/services/leadmanagement/DeactivateLeadByRefId
Body:
referenceIds: URL encoded string
Params:
resultCode: string,
scope: integer,
listId: int,
updateHistory: boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • A Content-Type header of ‘application/x-www-form-urlencoded’ is required for this API method.
  • The list of reference IDs should be passed as a URL-encoded JSON string.
    For instance, to deactivate leads with the reference IDs; “123” and “ABC”, the following JSON array would be produced: ‘["123","ABC"]’. This would then need to be URL encoded to ‘%5B%22123%22%2C%22ABC%22%5D’. So, the full body of the request would be: ‘referenceIds=%5B%22123%22%2C%22ABC%22%5D’
  • Consult the Common Parameters section for details of the resultCode, scope, listId and updateHistory parameters.


Example:


https://(customer).maxcontact.com/webservices/services/LeadManagement/DeactivateLeadByRefId/CUSTREF123ABC?Scope=0&listID=123&ResultCode=TEST&UpdateHistory=false


Param
Description*Default
ReferenceId
The reference ID in the database as imported.FN/A
ScopeGiven a phone number, decide which lead to deactivate.
You can kill all leads, the oldest leads or certain time-based leads.

Please refer to Appendix 2 for further details.
T0 (All)
ListIdThe list to remove the duplicate from. If this is set to 0, it will apply to all lists.T0 (All)
ResultCodeThe result code you want to use when deactivating the lead.T"API-Removed"
UpdateHistoryGo and find the last entry in History and change the result code to that specified. TFalse

(* = optional)


Back to Contents


Get Lead Info By Reference Id

API to retrieve lead and lead phone data based on a supplied reference ID.

GET
/webservices/services/leadmanagement/GetLeadInfoByReferenceId/{referenceId}
Params:
referenceId: string,
Returns:
An array of APILeadStatus entities (see Entities section)


Back to Contents


Move Lead By Phone Number

API to move a lead from one list to another based on the phone number of the lead.

POST
/webservices/services/leadmanagement/MoveLeadByPhone/{phoneNumber}
Params:
phoneNumber: string
newListId: integer
oldListId: integer
resetAttempts: Boolean
updateFinal: Boolean
finalCode: int
dncException: Boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The newListId parameter is a mandatory integer value that specifies the list that the lead(s) should be moved to.
  • The oldListId parameter is an optional integer value that can be supplied to cause the API to only move leads that are already in a particular list.
  • The resetAttempts parameter is an optional Boolean value, which, when passed a value of true, instructs the API to reset the attempt counts (stored against the lead and the lead phones) to zero.
  • The updateFinal parameter is an optional Boolean value that can be supplied with a value of true to cause the API to update the final code of the lead and lead phones.
  • The optional finalCode parameter makes it possible for the caller to supply a final code to be applied to the lead and lead phones if a value of true has also been supplied for the updateFinal parameter. If no value is supplied for the final code parameter, but the updateFinal parameter has been set to true, then the final code on the leads and lead phones will be set to ‘0 – None’. A full list of the available final codes is included in the appendix.
  • The dncException parameter is an optional Boolean parameter which tells the API whether or not to update the final code of any leads or lead phones that already have a final code of DNC.


Back to Contents


Move Lead By Reference Id

API to move a lead from one list to another based on a supplied reference ID.

POST
/webservices/services/leadmanagement/MoveLeadRefId/{referenceId}
Params:
referenceId: string
newListId: integer
oldListId: integer
resetAttempts: Boolean
updateFinal: Boolean
finalCode: int
dncException: Boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The newListId parameter is a mandatory integer value that specifies the list that the lead(s) should be moved to.
  • The parameters oldListId, resetAttempts, updateFinal, finalCode and dncException are all optional. Details of them can be found above in the section relating to the Move Lead By Phone Number method.


Back to Contents


Reactivate Lead By Id

API to make a single lead eligible for dialling based on a supplied lead ID.

POST
/webservices/services/leadmanagement/ReactivateLeadId/{leadId}
Params:
leadId: string
reactivateDnc: boolean
Returns:
ImportDataResult indicating success or failure


Back to Contents


Reactivate Leads By Phone Number

API to make one or more leads eligible for dialling based on a supplied phone number.

POST
/webservices/services/leadmanagement/ReactivateLeadByPhone/{phoneNumber}
Params:
phoneNumber: string,
listId: int,
reactivateDnc: boolean
Returns:
ImportDataResult indicating success or failure


Back to Contents


Reactivate Leads By Reference Id

API to make lead(s) eligible for dialling based on a supplied reference ID value.

POST
/webservices/services/leadmanagement/ReactivateLeadByRefId/{referenceId}
Params:
referenceId: string,
listId: int,
reactivateDnc: boolean
Returns:
ImportDataResult indicating success or failure


Back to Contents


Reactivate Leads By Reference Ids

API to make multiple leads eligible for dialling based on a supplied list of reference IDs.

POST
/webservices/services/leadmanagement/ReactivateLeadByRefIds
Body:
referenceIds: URL encoded string
Params:
listId: int,
reactivateDnc: boolean
Returns:
ImportDataResult indicating success or failure


Back to Contents


Update Lead Phone By Phone Number

API to update the phone number recorded against a lead.

POST
/webservices/services/leadmanagement/UpdateLeadPhoneByPhoneNum/{phoneNum}
Params:
phoneNum: string
newPhone: string
listId: integer
reset: Boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The phoneNum parameter is a mandatory parameter that identifies to phone number to be updated.
  • The newPhone parameter is a mandatory parameter that allows the API caller to supply the new phone number that should be used.
  • The listId parameter is an optional integer ID value that makes it possible to only update the phone number of a lead within a particular list.
  • The reset parameter is an optional Boolean value which, when passed a value of true, instructs the API to reset the attempt counts (stored against the lead and the lead phones) to zero.


Back to Contents


Update Lead Phone By Reference Id

API to update the phone number recorded against a lead using a reference ID to locate the lead to be updated.

POST
/webservices/services/leadmanagement/UpdateLeadPhoneByPhoneNum/{referenceId}
Params:
referenceId
oldPhone: string
newPhone: string
listId: integer
reset: Boolean
Returns:
ImportDataResult indicating success or failure

Notes

  • The oldPhone parameter is a mandatory string parameter that identifies the old phone number to be updated. This parameter is required as leads often have multiple phone numbers associated with them, and the API needs to know which of the old phone numbers to update.
  • The newPhone parameter is a mandatory parameter that allows the API caller to supply the new phone number that should be used.
  • The listId parameter is an optional integer ID value that makes it possible to only update the phone number of a lead within a particular list.
  • The reset parameter is an optional Boolean value which, when passed a value of true, instructs the API to reset the attempt counts (stored against the lead and the lead phones) to zero.


Back to Contents


Bulk Lead Loading Methods

The API offers several options for the bulk loading of lead data from either CSV, JSON or XML formatted files.

POST
/webservices/services/leadmanagement/ImportCsvFiles
/webservices/services/leadmanagement/ImportJsonFiles
/webservices/services/leadmanagement/ImportXmlFiles
BodyParams:
FileName: string
MapName: string
File: filecontent
Returns:
ImportDataResult indicating success or failure

Notes

To use any of the bulk lead loading API methods, you are required to use a multipart FORM POST containing an octet stream. Please ensure you are fully aware of this method for HTTP Transport.

https://en.wikipedia.org/wiki/MIME#Multipart_messages

https://tools.ietf.org/html/rfc2388


Creating an Import Mapping

Import mappings need to be created before the bulk loading of leads will work. To do this, you will need to access the Import API Mappings page within the Manager Portal.


In the mapping, you can specify key details of the import, such as the list to import into, the priority of the import, deduplication and do not call checking, along with mappings of which CSV columns map to which Max Contact database columns.


Attaching the File to Import

The CSV file to be uploaded can have as many columns as required. A separate mapper page can be found in the Manager Portal to assign these custom columns to the correct MaxContact data columns. Please contact your MaxContact installer to arrange mapping.


Example CSV format

phone,id,first_name,last_name
“01234567890”,1,“joe”,”blogs”


Options

It is possible to control some of the actions of the import using an options parameter in the header. This should be a JSON object containing the settings. Some options may be ignored if the master configuration of the import is set to do so, such as ListID when an import is done to an already specified list, etc.


Headers

The Following headers need to be added to your request.


Content-Type: multipart/form-data; boundary=[YOUR DELIMITER] 

Cookie: TokenKey=[YOUR TOKEN]



Mandatory Params


FileName


In the multipart section for the octet/stream, it is required that a filename is in place.


Filename=somefilename.csv


MapName


A mapname is the name of the template you are going to be using to map the data into the import system. For each lead supplier, a different template can be supplied in the options.


Add this key to the multi-part content mapname=template1


Example Multipart Content

--DELIMITER
Content-Disposition: form-data; name="CSV Upload"; filename="filename.csv Content-Type: application/octet-stream
first_name,last_name,reference,mobile,home,work
“Joe","Bloggs","abc","9876543210","9876543210","9876543210
“Jane","Bloggs","def","9876543210","9876543210","9876543210

--DELIMITER
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="mapname"

My Mapping

--DELIMITER
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="options"

[JSON Optional Parameters]}

--DELIMITER--


Optional Parameters

Field

Data Type

ListIDInteger
SecondaryEnabledBoolean
CheckDNCBoolean
DedupeBoolean
RemoveNonDigitsBoolean
TruncateExtraDigitsBoolean


Response When Bulk Imports Complete

To receive an HTTP POST response when an import has failed or completed, a Response URL must be provided when setting up the Import API Mapping.


https://[CUSTOMER].maxcontact.com/ManagerPortal/ImportMapper


When the import completes, MaxContact will make a request to the supplied URL with an “ImportDataResponse” object, which will detail which rows have been rejected and the reasons why. Below is an XML example; however, if you require this to be JSON, this will need to be configured in the mapping.


<LeadAPIResult.ImportDataResponse
xmlns="http://schemas.datacontract.org/2004/07/Max.LeadManagement.LeadAPIPublic"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Errors xmlns:a="http://schemas.datacontract.org/2004/07/Max.LeadManagement.APIError">
<a:APIError>
<a:ErrorCode>GeneralInfo</a:ErrorCode>
<a:ErrorSeverity>Info</a:ErrorSeverity>
<a:ErrorText>Line: 1 Reason: Duplicate</a:ErrorText>
</a:APIError>
<a:APIError>
<a:ErrorCode>GeneralInfo</a:ErrorCode>
<a:ErrorSeverity>Info</a:ErrorSeverity>
<a:ErrorText>Line: 2 Reason: DoNotCall</a:ErrorText>
</a:APIError>
<a:APIError>
<a:ErrorCode>GeneralInfo</a:ErrorCode>
<a:ErrorSeverity>Info</a:ErrorSeverity>
<a:ErrorText>Line: 3 Reason: DuplicateInFile</a:ErrorText>
</a:APIError>
<a:APIError>
<a:ErrorCode>GeneralInfo</a:ErrorCode>
<a:ErrorSeverity>Info</a:ErrorSeverity>
<a:ErrorText>Line: 4 Reason: InvalidSourceFormat</a:ErrorText>
</a:APIError>
<a:APIError>
<a:ErrorCode>GeneralInfo</a:ErrorCode>
<a:ErrorSeverity>Info</a:ErrorSeverity>
<a:ErrorText>Line: 5 Reason: InvalidPhoneNumber</a:ErrorText>
</a:APIError>
</Errors>
<ImmediateRejectCount>0</ImmediateRejectCount>
<ImportIDs i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<LeadsImported>100</LeadsImported >
<RejectedDedupe>1</RejectedDedupe>
<RejectedDedupeFile>1</RejectedDedupeFile>
<RejectedDnc>1</RejectedDnc>
<RejectedParsing>1</RejectedParsing>
<RejectedValidation>1</RejectedValidation >
<Success>false</Success>
</LeadAPIResult.ImportDataResponse >


You can configure whether the response format is in either XML or JSON via the Import API Mapping page in Manager Portal.


https://[CUSTOMER].maxcontact.com/ManagerPortal/ImportMapper


Back to Contents



Add Lead

NOTE: This endpoint should only be used if other mechanisms of adding leads have been exhausted. This has no auditing and no validation checks.

POST
/webservices/services/leadmanagement/addlead
Body:
{
Title: string, // Personal title (Mr, Ms, Dr etc.)
Name: string, // Forename
Name2: string, // Surname
Address: string, // First line of address
Address2: string, // Second line of address
City: string, // City
State: string, // State
PostalCode: string, // Postal code
ReferenceID: string, // Optional external reference for the lead
Supplier: string, // Supplier of the lead data
Cost: decimal, // Cost of the lead data
ListID: integer, // Id of the list the lead should be added to
ReferenceField: string, //
OtherInfo: string, // Extra info to be displayed to the agent
LeadPhones: [
{
PhoneNum: string, // Phone number or contact details
PhoneTypeID: integer, // Type of phone number (e.g. work, home)
CanCallDate: datetime, // Earliest date the lead can be called
TimeZoneID: integer, // Time zone where the lead is located
IsHighPriority: Boolean // High priority lead phones are called first
}
]
}
Returns:
ImportDataResult indicating success or containing any validation failures

Notes

  • Most of the data fields are optional (apart from List ID and Lead Phones), with defaults being applied if no value is supplied in the request.
  • At least one lead phone (with a phone number or other contact details) must be included in the request.
  • A valid List ID must be supplied; this ID is used to identify an existing list that the new lead should be added to. List IDs can be obtained from the Lists page in Manager Portal or from the corresponding table in the application database.
  • Date time values should be supplied in ISO8601 format in the local time zone.
  • Consult the appendix for details of available Phone Type ID values and Time Zone IDs.


Back to Contents


Errors and Error Handling


Token Errors

A null or undefined token is a sign of an error; any HTTP Response Codes other than 200 OK are also a sign of an error.


Import API Errors

When a Lead API action is called, it will return an object of "ImportDataResult" (in either XML or JSON, depending on your request options).

This class contains an overview of the success of the request and any other useful information.

For example, an Import request will return an ImportDataResult with a number of ImmediateRejectCounts. The error array will contain details of the issue causing the immediate rejection of a lead.


Object Definitions

An API error is a list of errors that occurred during the lead API process.  For example, it may return the following:

{ 

    ErrorId = ErrorID.NoMapMatch, 

    ErrorText = "You do not have a valid map to import with", 

    ErrorSeverity = ErrorSeverities.Severe 

}

or

{ 

    ErrorId = ErrorID.GeneralWarning, 

    ErrorText = "There were a high number of rejected leads", 

    ErrorSeverity = ErrorSeverities.Warning 

}

*Please refer to Appendix 3 for the Error IDs and Appendix 4 for the Error Severities.


Back to Contents


Example Code


Get Token Example Code

Here is an example of how to create an authentication token for future API requests.

var targetUri = new Uri("https://[CUSTOMER].maxcontact.com/webservices/services/apitoken/login/{login}"); 

using (var httpClient = new HttpClient())

{

// Set buffer to a 10 megs for receiving large data sets        

httpClient.MaxResponseContentBufferSize = 10000000;

var base64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(password));        

httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", base64);

using (HttpResponseMessage response = await httpClient.GetAsync(targetUri))

using (HttpContent content = response.Content)

{

string httpResult = await content.ReadAsStringAsync();            

                if (httpResult.Length > 0)

                {

                        var token = (APIToken)Helper.XmlToObject(httpResult, typeof(APIToken));

                        return token;

                } 

        }      

}

Setting Token Example Code

var cookies = new CookieContainer(); cookies.Add(host, new Cookie("TokenKey", returnedToken.TokenKey));

var handler = new HttpClientHandler() { CookieContainer = cookies }) 


Bulk Load Leads Example Code

Here is a sample of using the API Lead Service in C# to bulk import leads.

Uri uri = new Uri("https://[CUSTOMER].maxcontact.com........")
FileInfo fi = new FileInfo(“[PATH TO YOUR FILE]”);        
string fileName = fi.Name;        
byte[] fileContents = File.ReadAllBytes(fi.FullName);


// open an HttpRequest object
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, uri);        
message.Headers.ExpectContinue = false;

// Fill out the cookie with the token obtained during auth        
CookieContainer cookies = new CookieContainer();        
cookies.Add(uri, new Cookie("TokenKey", "[YOUR TOKEN KEY]"));

// Create a new multipart content section
MultipartFormDataContent multiPartContent = new MultipartFormDataContent("--Max Test-");
ByteArrayContent byteArrayContent = new ByteArrayContent(fileContents);

// Its a stream!
byteArrayContent.Headers.Add("Content-Type", "application/octet-stream");        
multiPartContent.Add(byteArrayContent, "Test CSV Upload", fileName);

// These are all of the options for the server to process        
var formData = new[] {

                    // REQUIRED
                    new KeyValuePair<string, string>("mapname", "default"),
                    // any optional options here in Json
                    //new KeyValuePair<string, string>("options", "{ ListID: 1 }"), 
};

// Add the form fields to the request        
foreach (var kpv in formData)             
        multiPartContent.Add(new StringContent(kpv.Value), kpv.Key);

 message.Content = multiPartContent;

// Make the request
using (var handler = new HttpClientHandler() { CookieContainer = cookies })        
using (var client = new HttpClient(handler))
{            

        var httpRequest = client.SendAsync(message, HttpCompletionOption.ResponseContentRead);
        HttpResponseMessage httpResponse = httpRequest.Result;
        HttpStatusCode statusCode = httpResponse.StatusCode;
        HttpContent responseContent = httpResponse.Content;

        if (responseContent != null)
               var stringContentsTask = responseContent.ReadAsString();             
}


Back to Contents


Appendix

Appendix 1: Phone Types

The following table contains a list of the available phone types as recorded against each record in the lead phone table. This value is used to identify what type of contact details the lead phone record relates to.


ID

Description

0Home
1Work
2Mobile
3Home Email
4Work Email
5Messenger


Appendix 2: Lead Deactivation Scope

When deactivating leads, it is possible to supply a deactivation scope value that will restrict the set of leads that are deactivated. The table below details the set of available values for the deactivation scope.


ID

Name

Description

0AllAll related leads will be deactivated.
1Keep NewestAll leads apart from the one that was most recently imported should be deactivated.
2Over 6m OldDeactivate leads that were imported more than six months ago.
3Over 12m OldDeactivate leads that were imported more than twelve months ago.

Appendix 3: API Error Codes

Errors reported by the API methods will often be classified using one of the following error codes.


ID

Name

0NotAuth
1GeneralInfo
2GeneralWarning
3GeneralError
4FileMissing
5FileTooLarge
6FileWriteError
7CommsError
8DBError
9NoMapMatch
10NoMapFound
11InvalidLead
12InvalidLeadId
13PhoneNumberNotFound
14NoHistoryEntry
15LeadInUse


Appendix 4: API Error Severities

Errors reported by the API methods will often be classified using one of the following error severities.


ID

Name

0None
1Info
2Warning
3Severe


Appendix 5: Final Codes

Final codes are values that can be applied to both leads and lead phones to indicate their final status.


ID

Name

0None
1Final Result
2DNC
3Max Attempts
4Private Callback
5Rollover
6Max Attempt Rollover
50Deactivated By Lead Management
51Lead Management
100Expired


Appendix 6: Time Zones

The system uses the Windows time zone. The following table contains details of these.


ID

Name

Display Name

0UnknownUnknown
1Dateline Standard Time (UTC-12:00) International Date Line West
2UTC-11 (UTC-11:00) Coordinated Universal Time-11
3Aleutian Standard Time (UTC-10:00) Aleutian Islands
4Hawaiian Standard Time (UTC-10:00) Hawaii
5Marquesas Standard Time (UTC-09:30) Marquesas Islands
6Alaskan Standard Time (UTC-09:00) Alaska
7UTC-09 (UTC-09:00) Coordinated Universal Time-09
8Pacific Standard Time (Mexico) (UTC-08:00) Baja California
9UTC-08 (UTC-08:00) Coordinated Universal Time-08
10Pacific Standard Time (UTC-08:00) Pacific Time (US & Canada)
11US Mountain Standard Time (UTC-07:00) Arizona
12Mountain Standard Time(Mexico)(UTC-07:00) La Paz, Mazatlan
13Mountain Standard Time (UTC-07:00) Mountain Time (US & Canada)
14Yukon Standard Time (UTC-07:00) Yukon
15Central America Standard Time (UTC-06:00) Central America
16Central Standard Time (UTC-06:00) Central Time (US & Canada)
17Easter Island Standard Time (UTC-06:00) Easter Island
18Central Standard Time (Mexico) (UTC-06:00) Guadalajara, Mexico City, Monterrey
19Canada Central Standard Time (UTC-06:00) Saskatchewan
20SA Pacific Standard Time (UTC-05:00) Bogota, Lima, Quito, Rio Branco
21Eastern Standard Time (Mexico) (UTC-05:00) Chetumal
22Eastern Standard Time (UTC-05:00) Eastern Time (US & Canada)
23Haiti Standard Time (UTC-05:00) Haiti
24Cuba Standard Time (UTC-05:00) Havana
25US Eastern Standard Time (UTC-05:00) Indiana (East)
26Turks And Caicos Standard Time (UTC-05:00) Turks and Caicos
27Paraguay Standard Time (UTC-04:00) Asuncion
28Atlantic Standard Time (UTC-04:00) Atlantic Time (Canada)
29Venezuela Standard Time (UTC-04:00) Caracas
30Central Brazilian Standard Time (UTC-04:00) Cuiaba
31SA Western Standard Time (UTC-04:00) Georgetown, La Paz, Manaus, San Juan
32Pacific SA Standard Time (UTC-04:00) Santiago
33Newfoundland Standard Time (UTC-03:30) Newfoundland
34Tocantins Standard Time (UTC-03:00) Araguaina
35E. South America Standard Time (UTC-03:00) Brasilia
36SA Eastern Standard Time (UTC-03:00) Cayenne, Fortaleza
37Argentina Standard Time (UTC-03:00) City of Buenos Aires
38Montevideo Standard Time (UTC-03:00) Montevideo
39Magallanes Standard Time (UTC-03:00) Punta Arenas
40Saint Pierre Standard Time (UTC-03:00) Saint Pierre and Miquelon
41Bahia Standard Time (UTC-03:00) Salvador
42UTC-02 (UTC-02:00) Coordinated Universal Time-02
43Greenland Standard Time (UTC-02:00) Greenland
44Mid-Atlantic Standard Time (UTC-02:00) Mid-Atlantic - Old
45Azores Standard Time (UTC-01:00) Azores
46Cape Verde Standard Time (UTC-01:00) Cabo Verde Is.
47UTC (UTC) Coordinated Universal Time
48GMT Standard Time (UTC+00:00) Dublin, Edinburgh, Lisbon, London
49Greenwich Standard Time (UTC+00:00)     Monrovia, Reykjavik
50Sao Tome Standard Time (UTC+00:00) Sao Tome
51Morocco Standard Time (UTC+01:00) Casablanca
52W. Europe Standard Time (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
53Central Europe Standard Time (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
54Romance Standard Time (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
55Central European Standard Time (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
56W. Central Africa Standard Time (UTC+01:00) West Central Africa
57GTB Standard Time (UTC+02:00) Athens, Bucharest
58Middle East Standard Time (UTC+02:00) Beirut
59Egypt Standard Time (UTC+02:00) Cairo
60E. Europe Standard Time (UTC+02:00) Chisinau
61West Bank Standard Time (UTC+02:00) Gaza, Hebron
62South Africa Standard Time (UTC+02:00) Harare, Pretoria
63FLE Standard Time (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
64Israel Standard Time (UTC+02:00) Jerusalem
65South Sudan Standard Time (UTC+02:00) Juba
66Kaliningrad Standard Time (UTC+02:00) Kaliningrad
67Sudan Standard Time (UTC+02:00) Khartoum
68Libya Standard Time (UTC+02:00) Tripoli
69Namibia Standard Time (UTC+02:00) Windhoek
70Jordan Standard Time (UTC+03:00) Amman
71Arabic Standard Time (UTC+03:00) Baghdad
72Syria Standard Time (UTC+03:00) Damascus
73Turkey Standard Time (UTC+03:00) Istanbul
74Arab Standard Time (UTC+03:00) Kuwait, Riyadh
75Belarus Standard Time (UTC+03:00) Minsk
76Russian Standard Time (UTC+03:00) Moscow, St. Petersburg
77E. Africa Standard Time (UTC+03:00) Nairobi
78Volgograd Standard Time (UTC+03:00) Volgograd
79Iran Standard Time (UTC+03:30) Tehran
80Arabian Standard Time (UTC+04:00) Abu Dhabi, Muscat
81Astrakhan Standard Time (UTC+04:00) Astrakhan, Ulyanovsk
82Azerbaijan Standard Time (UTC+04:00) Baku
83Russia Time Zone 3 (UTC+04:00) Izhevsk, Samara
84Mauritius Standard Time (UTC+04:00) Port Louis
85Saratov Standard Time (UTC+04:00) Saratov
86Georgian Standard Time (UTC+04:00) Tbilisi
87Caucasus Standard Time (UTC+04:00) Yerevan
88Afghanistan Standard Time (UTC+04:30) Kabul
89West Asia Standard Time (UTC+05:00) Ashgabat, Tashkent
90Qyzylorda Standard Time (UTC+05:00) Astana
91Ekaterinburg Standard Time (UTC+05:00) Ekaterinburg
92Pakistan Standard Time (UTC+05:00) Islamabad, Karachi
93India Standard Time (UTC+05:30)  Chennai, Kolkata, Mumbai, New Delhi
94Sri Lanka Standard Time (UTC+05:30) Sri Jayawardenepura
95Nepal Standard Time (UTC+05:45) Kathmandu
96Central Asia Standard Time (UTC+06:00) Bishkek
97Bangladesh Standard Time (UTC+06:00) Dhaka
98Omsk Standard Time (UTC+06:00) Omsk
99Myanmar Standard Time (UTC+06:30) Yangon (Rangoon)
100SE Asia Standard Time (UTC+07:00) Bangkok, Hanoi, Jakarta
101Altai Standard Time (UTC+07:00) Barnaul, Gorno-Altaysk
102W. Mongolia Standard Time (UTC+07:00) Hovd
103North Asia Standard Time (UTC+07:00) Krasnoyarsk
104N. Central Asia Standard Time (UTC+07:00) Novosibirsk
105Tomsk Standard Time (UTC+07:00) Tomsk
106China Standard Time (UTC+08:00)  Beijing, Chongqing, Hong Kong, Urumqi
107North Asia East Standard Time (UTC+08:00) Irkutsk
108Singapore Standard Time (UTC+08:00) Kuala Lumpur, Singapore
109W. Australia Standard Time (UTC+08:00) Perth
110Taipei Standard Time (UTC+08:00) Taipei
111Ulaanbaatar Standard Time (UTC+08:00) Ulaanbaatar
112Aus Central W. Standard Time (UTC+08:45) Eucla
113Transbaikal Standard Time (UTC+09:00) Chita
114Tokyo Standard Time (UTC+09:00) Osaka, Sapporo, Tokyo
115North Korea Standard Time (UTC+09:00) Pyongyang
116Korea Standard Time (UTC+09:00) Seoul
117Yakutsk Standard Time (UTC+09:00) Yakutsk
118Cen. Australia Standard Time (UTC+09:30) Adelaide
119AUS Central Standard Time (UTC+09:30) Darwin
120E. Australia Standard Time (UTC+10:00) Brisbane
121AUS Eastern Standard Time (UTC+10:00) Canberra, Melbourne, Sydney
122West Pacific Standard Time (UTC+10:00) Guam,     Port Moresby
123Tasmania Standard Time (UTC+10:00) Hobart
124Vladivostok Standard Time (UTC+10:00) Vladivostok
125Lord Howe Standard Time (UTC+10:30) Lord Howe Island
126Bougainville Standard Time (UTC+11:00) Bougainville Island
127Russia Time Zone 10 (UTC+11:00) Chokurdakh
128Magadan Standard Time (UTC+11:00) Magadan
129Norfolk Standard Time (UTC+11:00) Norfolk Island
130Sakhalin Standard Time (UTC+11:00) Sakhalin
131Central Pacific Standard Time (UTC+11:00) Solomon Is., New Caledonia
132Russia Time Zone 11 (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky
133New Zealand Standard Time (UTC+12:00) Auckland,  Wellington
134UTC+12 (UTC+12:00) Coordinated Universal Time+12
135Fiji Standard Time (UTC+12:00) Fiji
136Kamchatka Standard Time (UTC+12:00) Petropavlovsk-Kamchatsky - Old
137Chatham Islands Standard Time (UTC+12:45) Chatham Islands
138UTC+13 (UTC+13:00) Coordinated Universal Time+13
139Tonga Standard Time (UTC+13:00) Nuku'alofa
140Samoa Standard Time (UTC+13:00) Samoa
141Line Islands Standard Time (UTC+14:00) Kiritimati Island
142Pacific-Mountain Ambiguous (UTC-07:00) - (UTC-08:00) Pacific -Mountain Ambiguous
143Mountain-Central Ambiguous (UTC-06:00) - (UTC-07:00) Mountain-Central Ambiguous
144Central-Eastern Ambiguous (UTC-05:00) - (UTC-06:00) Central-Eastern Ambiguous
145Atlantic-Newfoundland Ambiguous(UTC-03:30) - (UTC-04:00) Atlantic-Newfoundland Ambiguous


Back to Contents