TABLE OF CONTENTS [Document Version - 2.0]
- Contents
- Cheat Sheet
- Usage
- Common API Parameters
- Lead Activation and Deactivation Parameters
- Important Notes
- Authentication
- Tokens API
- Responses
- Methods
- Deactivate Lead by Id
- Deactivate Leads by Id
- Deactivate Leads by Phone Number
- Deactivate Leads by Reference Id
- Deactivate Leads by Reference Ids
- Get Lead Info by Reference Id
- Move Lead by Phone Number
- Move Lead by Reference Id
- Reactivate Lead by Id
- Reactivate Leads by Phone Number
- Reactivate Leads by Reference Id
- Reactivate Leads by Reference Ids
- Update Lead Phone by Phone Number
- Update Lead Phone by Reference Id
- Bulk Lead Loading Methods
- Errors and Error Handling
- Example Code
- Appendix
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 Function | URL | Method | Version |
| Import a CSV file(s) | ImportCsvFiles | POST multi-part form | 2.6.0.1 |
Individual Lead Management Methods
These are RESTful requests formatted in the style of
Entity/Id/action
OR
Entity/Id?param1=x¶m2=y
| Method Function | URL | Params | Method | Version |
| Deactivate a Lead | DeactivateLeadByPhone | /{phoneNumber}?Scope={scope}&listID={listId} | DELETE | 2.6.0.1 |
| Deactivate a Lead | DeactivateLeadByRefId | /{referenceId}?Scope={scope}&listID={listId} | DELETE | 2.8.0 |
| Deactivate a Lead | DeactivateLeadId | /leadId | DELETE | 2.6.0.1 |
| Add a New Lead | AddLead | Post Request | POST | 2.8.5 |
| Bring Lead Back | ReactivateLeadByPhone | /{phoneNumber}?listID=listId}&reactivateDnc={reactivateDnc} | POST | 2.8.0 |
| Bring Lead Back | ReactivateLeadByLeadId | /{leadId}&reactivateDnc={reactivateDnc} | POST | 2.8.0 |
| Bring Lead Back | ReactivateLeadByLeadByRefId | /{referenceId}?listID={listId}&reactivateDnc={reactivateDnc} | POST | 2.8.0 |
| Move/Update Lead | MoveLeadByRefId | {phoneNumber}?newListID={newListId}&oldListID={oldListId}&resetAttempts={resetAttempts}&updateFinal={updateFinal}&finalCode={finalCode} | POST | 2.8.5 |
Full Process
- Authenticate and generate an API token.
- Call relevant API requests.
- 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'
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.
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
- Make a request to the token URI.
- Store the token key for any subsequent requests.
- 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.
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
}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 failureNotes
- 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
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 failureNotes
- 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.
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 failureNotes
- 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 |
| PhoneNumber | The given phone to kill. | F | N/A |
| Scope | Given 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. | T | 0 (All) |
| ListId | The list to remove the duplicate from. If this is set to 0, it will apply to all lists. | T | 0 (All) |
| ResultCode | The result code you want to use when deactivating the lead. | T | "API-Removed" |
| UpdateHistory | Go and find the last entry in History and change the result code to that specified. | T | False |
(* = optional)
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 failureNotes
- 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. | F | N/A |
| Scope | Given 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. | T | 0 (All) |
| ListId | The list to remove the duplicate from. If this is set to 0, it will apply to all lists. | T | 0 (All) |
| ResultCode | The result code you want to use when deactivating the lead. | T | "API-Removed" |
| UpdateHistory | Go and find the last entry in History and change the result code to that specified. | T | False |
(* = optional)
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. | F | N/A |
| Scope | Given 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. | T | 0 (All) |
| ListId | The list to remove the duplicate from. If this is set to 0, it will apply to all lists. | T | 0 (All) |
| ResultCode | The result code you want to use when deactivating the lead. | T | "API-Removed" |
| UpdateHistory | Go and find the last entry in History and change the result code to that specified. | T | False |
(* = optional)
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)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 failureNotes
- 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.
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 failureNotes
- 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.
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 failureReactivate 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 failureReactivate 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 failureReactivate 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
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 failureNotes
- 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.
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 failureNotes
- 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.
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 |
| ListID | Integer |
| SecondaryEnabled | Boolean |
| CheckDNC | Boolean |
| Dedupe | Boolean |
| RemoveNonDigits | Boolean |
| TruncateExtraDigits | Boolean |
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
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 failuresNotes
- 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.
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.
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();
}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 |
| 0 | Home |
| 1 | Work |
| 2 | Mobile |
| 3 | Home Email |
| 4 | Work Email |
| 5 | Messenger |
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 |
| 0 | All | All related leads will be deactivated. |
| 1 | Keep Newest | All leads apart from the one that was most recently imported should be deactivated. |
| 2 | Over 6m Old | Deactivate leads that were imported more than six months ago. |
| 3 | Over 12m Old | Deactivate 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 |
| 0 | NotAuth |
| 1 | GeneralInfo |
| 2 | GeneralWarning |
| 3 | GeneralError |
| 4 | FileMissing |
| 5 | FileTooLarge |
| 6 | FileWriteError |
| 7 | CommsError |
| 8 | DBError |
| 9 | NoMapMatch |
| 10 | NoMapFound |
| 11 | InvalidLead |
| 12 | InvalidLeadId |
| 13 | PhoneNumberNotFound |
| 14 | NoHistoryEntry |
| 15 | LeadInUse |
Appendix 4: API Error Severities
Errors reported by the API methods will often be classified using one of the following error severities.
ID | Name |
| 0 | None |
| 1 | Info |
| 2 | Warning |
| 3 | Severe |
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 |
| 0 | None |
| 1 | Final Result |
| 2 | DNC |
| 3 | Max Attempts |
| 4 | Private Callback |
| 5 | Rollover |
| 6 | Max Attempt Rollover |
| 50 | Deactivated By Lead Management |
| 51 | Lead Management |
| 100 | Expired |
Appendix 6: Time Zones
The system uses the Windows time zone. The following table contains details of these.
ID | Name | Display Name |
| 0 | Unknown | Unknown |
| 1 | Dateline Standard Time | (UTC-12:00) International Date Line West |
| 2 | UTC-11 | (UTC-11:00) Coordinated Universal Time-11 |
| 3 | Aleutian Standard Time | (UTC-10:00) Aleutian Islands |
| 4 | Hawaiian Standard Time | (UTC-10:00) Hawaii |
| 5 | Marquesas Standard Time | (UTC-09:30) Marquesas Islands |
| 6 | Alaskan Standard Time | (UTC-09:00) Alaska |
| 7 | UTC-09 | (UTC-09:00) Coordinated Universal Time-09 |
| 8 | Pacific Standard Time (Mexico) | (UTC-08:00) Baja California |
| 9 | UTC-08 | (UTC-08:00) Coordinated Universal Time-08 |
| 10 | Pacific Standard Time | (UTC-08:00) Pacific Time (US & Canada) |
| 11 | US Mountain Standard Time | (UTC-07:00) Arizona |
| 12 | Mountain Standard Time(Mexico) | (UTC-07:00) La Paz, Mazatlan |
| 13 | Mountain Standard Time | (UTC-07:00) Mountain Time (US & Canada) |
| 14 | Yukon Standard Time | (UTC-07:00) Yukon |
| 15 | Central America Standard Time | (UTC-06:00) Central America |
| 16 | Central Standard Time | (UTC-06:00) Central Time (US & Canada) |
| 17 | Easter Island Standard Time | (UTC-06:00) Easter Island |
| 18 | Central Standard Time (Mexico) | (UTC-06:00) Guadalajara, Mexico City, Monterrey |
| 19 | Canada Central Standard Time | (UTC-06:00) Saskatchewan |
| 20 | SA Pacific Standard Time | (UTC-05:00) Bogota, Lima, Quito, Rio Branco |
| 21 | Eastern Standard Time (Mexico) | (UTC-05:00) Chetumal |
| 22 | Eastern Standard Time | (UTC-05:00) Eastern Time (US & Canada) |
| 23 | Haiti Standard Time | (UTC-05:00) Haiti |
| 24 | Cuba Standard Time | (UTC-05:00) Havana |
| 25 | US Eastern Standard Time | (UTC-05:00) Indiana (East) |
| 26 | Turks And Caicos Standard Time | (UTC-05:00) Turks and Caicos |
| 27 | Paraguay Standard Time | (UTC-04:00) Asuncion |
| 28 | Atlantic Standard Time | (UTC-04:00) Atlantic Time (Canada) |
| 29 | Venezuela Standard Time | (UTC-04:00) Caracas |
| 30 | Central Brazilian Standard Time | (UTC-04:00) Cuiaba |
| 31 | SA Western Standard Time | (UTC-04:00) Georgetown, La Paz, Manaus, San Juan |
| 32 | Pacific SA Standard Time | (UTC-04:00) Santiago |
| 33 | Newfoundland Standard Time | (UTC-03:30) Newfoundland |
| 34 | Tocantins Standard Time | (UTC-03:00) Araguaina |
| 35 | E. South America Standard Time | (UTC-03:00) Brasilia |
| 36 | SA Eastern Standard Time | (UTC-03:00) Cayenne, Fortaleza |
| 37 | Argentina Standard Time | (UTC-03:00) City of Buenos Aires |
| 38 | Montevideo Standard Time | (UTC-03:00) Montevideo |
| 39 | Magallanes Standard Time | (UTC-03:00) Punta Arenas |
| 40 | Saint Pierre Standard Time | (UTC-03:00) Saint Pierre and Miquelon |
| 41 | Bahia Standard Time | (UTC-03:00) Salvador |
| 42 | UTC-02 | (UTC-02:00) Coordinated Universal Time-02 |
| 43 | Greenland Standard Time | (UTC-02:00) Greenland |
| 44 | Mid-Atlantic Standard Time | (UTC-02:00) Mid-Atlantic - Old |
| 45 | Azores Standard Time | (UTC-01:00) Azores |
| 46 | Cape Verde Standard Time | (UTC-01:00) Cabo Verde Is. |
| 47 | UTC | (UTC) Coordinated Universal Time |
| 48 | GMT Standard Time | (UTC+00:00) Dublin, Edinburgh, Lisbon, London |
| 49 | Greenwich Standard Time | (UTC+00:00) Monrovia, Reykjavik |
| 50 | Sao Tome Standard Time | (UTC+00:00) Sao Tome |
| 51 | Morocco Standard Time | (UTC+01:00) Casablanca |
| 52 | W. Europe Standard Time | (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna |
| 53 | Central Europe Standard Time | (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague |
| 54 | Romance Standard Time | (UTC+01:00) Brussels, Copenhagen, Madrid, Paris |
| 55 | Central European Standard Time | (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb |
| 56 | W. Central Africa Standard Time | (UTC+01:00) West Central Africa |
| 57 | GTB Standard Time | (UTC+02:00) Athens, Bucharest |
| 58 | Middle East Standard Time | (UTC+02:00) Beirut |
| 59 | Egypt Standard Time | (UTC+02:00) Cairo |
| 60 | E. Europe Standard Time | (UTC+02:00) Chisinau |
| 61 | West Bank Standard Time | (UTC+02:00) Gaza, Hebron |
| 62 | South Africa Standard Time | (UTC+02:00) Harare, Pretoria |
| 63 | FLE Standard Time | (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius |
| 64 | Israel Standard Time | (UTC+02:00) Jerusalem |
| 65 | South Sudan Standard Time | (UTC+02:00) Juba |
| 66 | Kaliningrad Standard Time | (UTC+02:00) Kaliningrad |
| 67 | Sudan Standard Time | (UTC+02:00) Khartoum |
| 68 | Libya Standard Time | (UTC+02:00) Tripoli |
| 69 | Namibia Standard Time | (UTC+02:00) Windhoek |
| 70 | Jordan Standard Time | (UTC+03:00) Amman |
| 71 | Arabic Standard Time | (UTC+03:00) Baghdad |
| 72 | Syria Standard Time | (UTC+03:00) Damascus |
| 73 | Turkey Standard Time | (UTC+03:00) Istanbul |
| 74 | Arab Standard Time | (UTC+03:00) Kuwait, Riyadh |
| 75 | Belarus Standard Time | (UTC+03:00) Minsk |
| 76 | Russian Standard Time | (UTC+03:00) Moscow, St. Petersburg |
| 77 | E. Africa Standard Time | (UTC+03:00) Nairobi |
| 78 | Volgograd Standard Time | (UTC+03:00) Volgograd |
| 79 | Iran Standard Time | (UTC+03:30) Tehran |
| 80 | Arabian Standard Time | (UTC+04:00) Abu Dhabi, Muscat |
| 81 | Astrakhan Standard Time | (UTC+04:00) Astrakhan, Ulyanovsk |
| 82 | Azerbaijan Standard Time | (UTC+04:00) Baku |
| 83 | Russia Time Zone 3 | (UTC+04:00) Izhevsk, Samara |
| 84 | Mauritius Standard Time | (UTC+04:00) Port Louis |
| 85 | Saratov Standard Time | (UTC+04:00) Saratov |
| 86 | Georgian Standard Time | (UTC+04:00) Tbilisi |
| 87 | Caucasus Standard Time | (UTC+04:00) Yerevan |
| 88 | Afghanistan Standard Time | (UTC+04:30) Kabul |
| 89 | West Asia Standard Time | (UTC+05:00) Ashgabat, Tashkent |
| 90 | Qyzylorda Standard Time | (UTC+05:00) Astana |
| 91 | Ekaterinburg Standard Time | (UTC+05:00) Ekaterinburg |
| 92 | Pakistan Standard Time | (UTC+05:00) Islamabad, Karachi |
| 93 | India Standard Time | (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi |
| 94 | Sri Lanka Standard Time | (UTC+05:30) Sri Jayawardenepura |
| 95 | Nepal Standard Time | (UTC+05:45) Kathmandu |
| 96 | Central Asia Standard Time | (UTC+06:00) Bishkek |
| 97 | Bangladesh Standard Time | (UTC+06:00) Dhaka |
| 98 | Omsk Standard Time | (UTC+06:00) Omsk |
| 99 | Myanmar Standard Time | (UTC+06:30) Yangon (Rangoon) |
| 100 | SE Asia Standard Time | (UTC+07:00) Bangkok, Hanoi, Jakarta |
| 101 | Altai Standard Time | (UTC+07:00) Barnaul, Gorno-Altaysk |
| 102 | W. Mongolia Standard Time | (UTC+07:00) Hovd |
| 103 | North Asia Standard Time | (UTC+07:00) Krasnoyarsk |
| 104 | N. Central Asia Standard Time | (UTC+07:00) Novosibirsk |
| 105 | Tomsk Standard Time | (UTC+07:00) Tomsk |
| 106 | China Standard Time | (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi |
| 107 | North Asia East Standard Time | (UTC+08:00) Irkutsk |
| 108 | Singapore Standard Time | (UTC+08:00) Kuala Lumpur, Singapore |
| 109 | W. Australia Standard Time | (UTC+08:00) Perth |
| 110 | Taipei Standard Time | (UTC+08:00) Taipei |
| 111 | Ulaanbaatar Standard Time | (UTC+08:00) Ulaanbaatar |
| 112 | Aus Central W. Standard Time | (UTC+08:45) Eucla |
| 113 | Transbaikal Standard Time | (UTC+09:00) Chita |
| 114 | Tokyo Standard Time | (UTC+09:00) Osaka, Sapporo, Tokyo |
| 115 | North Korea Standard Time | (UTC+09:00) Pyongyang |
| 116 | Korea Standard Time | (UTC+09:00) Seoul |
| 117 | Yakutsk Standard Time | (UTC+09:00) Yakutsk |
| 118 | Cen. Australia Standard Time | (UTC+09:30) Adelaide |
| 119 | AUS Central Standard Time | (UTC+09:30) Darwin |
| 120 | E. Australia Standard Time | (UTC+10:00) Brisbane |
| 121 | AUS Eastern Standard Time | (UTC+10:00) Canberra, Melbourne, Sydney |
| 122 | West Pacific Standard Time | (UTC+10:00) Guam, Port Moresby |
| 123 | Tasmania Standard Time | (UTC+10:00) Hobart |
| 124 | Vladivostok Standard Time | (UTC+10:00) Vladivostok |
| 125 | Lord Howe Standard Time | (UTC+10:30) Lord Howe Island |
| 126 | Bougainville Standard Time | (UTC+11:00) Bougainville Island |
| 127 | Russia Time Zone 10 | (UTC+11:00) Chokurdakh |
| 128 | Magadan Standard Time | (UTC+11:00) Magadan |
| 129 | Norfolk Standard Time | (UTC+11:00) Norfolk Island |
| 130 | Sakhalin Standard Time | (UTC+11:00) Sakhalin |
| 131 | Central Pacific Standard Time | (UTC+11:00) Solomon Is., New Caledonia |
| 132 | Russia Time Zone 11 | (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky |
| 133 | New Zealand Standard Time | (UTC+12:00) Auckland, Wellington |
| 134 | UTC+12 | (UTC+12:00) Coordinated Universal Time+12 |
| 135 | Fiji Standard Time | (UTC+12:00) Fiji |
| 136 | Kamchatka Standard Time | (UTC+12:00) Petropavlovsk-Kamchatsky - Old |
| 137 | Chatham Islands Standard Time | (UTC+12:45) Chatham Islands |
| 138 | UTC+13 | (UTC+13:00) Coordinated Universal Time+13 |
| 139 | Tonga Standard Time | (UTC+13:00) Nuku'alofa |
| 140 | Samoa Standard Time | (UTC+13:00) Samoa |
| 141 | Line Islands Standard Time | (UTC+14:00) Kiritimati Island |
| 142 | Pacific-Mountain Ambiguous | (UTC-07:00) - (UTC-08:00) Pacific -Mountain Ambiguous |
| 143 | Mountain-Central Ambiguous | (UTC-06:00) - (UTC-07:00) Mountain-Central Ambiguous |
| 144 | Central-Eastern Ambiguous | (UTC-05:00) - (UTC-06:00) Central-Eastern Ambiguous |
| 145 | Atlantic-Newfoundland Ambiguous | (UTC-03:30) - (UTC-04:00) Atlantic-Newfoundland Ambiguous |