This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Leads in Marketo



Overview

The following operations allow you to work with leads. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with leads, see Sample configuration.

OperationDescription
getLeadByIdRetrieves a lead for a given Marketo Id.
getMultipleLeadsByFilterTypeRetrieves multiple leads for given search criteria.
getMultipleLeadsByListIdRetrieves multiple leads from a list with the given list id.
createAndUpdateLeadsCreates a new lead or Updates an existing lead.
associateLeadAssociates a lead with a cookie value.
mergeLeadMerges two leads(Losing lead with winning lead).
getLeadPartitionsRetrieves a list of lead partitions in a Marketo instance.
getMultipleLeadsByProgramIdRetrieves multiple leads from a given program id.
deleteLeadDeletes leads with the given ids.
describeRetrieves all fields and the data type of a lead object.
importLeadImports leads in bulk.
getImportLeadStatusRetrieves the status of lead operation from ImportLead call.
getImportFailureFileRetrieves of the failure file from a ImportLead Call.
getImportWarningFileRetrieves of the warning file from a ImportLead Call.

Operation Details

This section provides further details on the operations related to leads.

Get Lead by Id

The getLeadById operation retrieves a lead for a given Marketo Id.

getLeadById
<marketo.getLeadById>
    <leadId>{$ctx:leadId}</leadId>
    <fields>{$ctx:fields}</fields>
</marketo.getLeadById>
properties
  • leadId: The Marketo Id of the lead.

  • fields: List of fields to be returned in response.

Sample request

Following is a sample REST/JSON request that can be handled by the getLeadById operation.

Sample request for getLeadById
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
  	"leadId":"11",
  	"fields":"lastName,email"
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-lead-by-id/

Get Multiple Leads By Filter Type

The getMultipleLeadsByFilterType operation retrieves multiple leads for given search criteria.

getMultipleLeadsByFilterType
<marketo.getMultipleLeadsByFilterType>
    <filterType>{$ctx:filterType}</filterType>
    <filterValues>{$ctx:filterValues}</filterValues>
    <fields>{$ctx:fields}</fields>
    <batchSize>{$ctx:batchSize}</batchSize>
    <nextPageToken>{$ctx:nextPageToken}</nextPageToken>
</marketo.getMultipleLeadsByFilterType>
properties
  • filterType: Filter type to retrieve the leads.

  • filterValues: Comma separated list of filter values.

  • fields: Comma separated list of fields to be returned in response.

  • batchSize: The number of lead records to be returned in a single call.

  • nextPageToken: Used to paginate through large result sets.

Sample Request

Following is a sample REST/JSON request that can be handled by the getMultipleLeadsByFilterType operation.

Sample request for getMultipleLeadsByFilterType
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "filterType":"id",
  	"filterValues":"387,390,393,398,399",
  	"fields":"lastName,firstName",
  	"batchSize":"3"
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-multiple-leads-by-filter-type/

Get Multiple Leads by List Id

The  getMultipleLeadsByListId operation retrieves multiple leads from a given list id.

getMultipleLeadsByListId
<marketo.getMultipleLeadsByListId>
    <listId>{$ctx:listId}</listId>
    <fields>{$ctx:fields}</fields>
    <batchSize>{$ctx:batchSize}</batchSize>
    <nextPageToken>{$ctx:nextPageToken}</nextPageToken>
</marketo.getMultipleLeadsByListId>
properties
  • listId: ID of the list.

  • fields : List of fields to be returned in response.

  • batchSize: The number of lead records to be returned in a single call.

  • nextPageToken: Used to paginate through large result sets.

Sample Request

Following is a sample REST/JSON request that can be handled by the  getMultipleLeadsByListId  operation.

Sample request for getMultipleLeadsByListId
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",  
 	"listId":"3",
  	"fields":"lastName",
 	"batchSize":"1",
 	"nextPageToken": "PS5VL5WD4UOWGOUCJR6VY7JQOZTXMC7UO74OEIV2HN4NCJZW32AA===="
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-multiple-leads-by-list-id/

Create and Update Leads

The  createAndUpdateLeads creates a new lead or updates an existing lead. 

createAndUpdateLeads
<marketo.createAndUpdateLeads>
    <input>{$ctx:input}</input>
    <action>{$ctx:action}</action>
    <lookupField>{$ctx:lookupField}</lookupField>
    <asyncProcessing>{$ctx:asyncProcessing}</asyncProcessing>
    <partitionName>{$ctx:partitionName}</partitionName>
</marketo.createAndUpdateLeads>
properties
  • input: Array of lead records to create or update.

  • action: The action need to be taken with this call.Possible values(createOnly,updateOnly,createOrUpdate(default request),createDuplicate)

  • lookupField: Attribute to find the duplicate.

  • asyncProcessing: Used to specify post processing when calling the creating/updating leads.

  • partitionName: Lead partition name.

Sample request 

Following is a sample REST/JSON request that can be handled by the createAndUpdateLeads operation.

Sample request for createAndUpdateLeads
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",  
 	"action":"updateOnly",
  	"lookupField":"email",
   	"partitionName":"default",
  	"asyncProcessing":"true",
   	"input":[  
      {  
         "email":"con-5@gmail.com",
         "firstName":"con-1",
         "postalCode":"04828"
      },
      {  
         "email":"con-4@gmail.com",
         "firstName":"con-2",
         "postalCode":"04828"
      },
      {  
         "email":"con-3@gmail.com",
         "firstName":"con-3",
         "postalCode":"04828"
      }
   ]
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/createupdate-leads/

Associate Lead

The associateLead operation associates a lead with a cookie value.

associateLead
<marketo.associateLead>
    <leadId>{$ctx:leadId}</leadId>
    <cookie>{$ctx:cookie}</cookie>
</marketo.associateLead>
properties
  • leadId: The Marketo Id of the lead.

  • cookie: Cookie value of lead.

Sample request

Following is a sample REST/JSON request that can be handled by the associateLead operation.

Sample request for associateLead
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
  	"leadId":"392",
  	"cookie":"id:287-GTJ-838%26token:_mch-marketo.com-1396310362214-46169"
}
Related Marketo documentation

Merge Lead

The mergeLead operation merges two leads(merges losing lead with winning lead).

mergeLead
<marketo.mergeLead>
    <wLeadId>{$ctx:wLeadId}</wLeadId>
    <lLeadId>{$ctx:lLeadId}</lLeadId>
    <mergeInCRM>{$ctx:mergeInCRM}</mergeInCRM>
</marketo.mergeLead>
properties
  • wLeadId: The Marketo Id of the winning lead.

  • lLeadId: The Marketo Id of the lead(losing) to be merged.

  • mergeInCRM: Set to true to merge in CRM.

Sample request

Following is a sample REST/JSON request that can be handled by the mergeLead operation.

Sample request for mergeLead
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
  	"wLeadId":"388",
 	"lLeadId":"387"
}
Related Marketo documentation

Get Lead Partitions

The getLeadPartitions operation retrieves a list of lead partitions in a Marketo instance.

getLeadPartitions
<marketo.getLeadPartitions/>
Sample request

Following is a sample REST/JSON request that can be handled by the getLeadPartitions operation.

Sample request for getLeadPartitions
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1"
}
Related Marketo documentation

getMultipleLeadsByProgramId

The getMultipleLeadsByProgramId operation retrieves multiple leads from a given program id.

getMultipleLeadsByProgramId
<marketo.getMultipleLeadsByProgramId>
    <programId>{$ctx:programId}</programId>
    <fields>{$ctx:fields}</fields>
    <batchSize>{$ctx:batchSize}</batchSize>
    <nextPageToken>{$ctx:nextPageToken}</nextPageToken>
</marketo.getMultipleLeadsByProgramId>
properties
  • programId: The Marketo Id of the program.

  • fields: List of fields to be returned in response.

  • batchSize: The number of lead records to be returned in a single call.

  • nextPageToken: Used to paginate through large result sets.

Sample request

Following is a sample REST/JSON request that can be handled by the getMultipleLeadsByProgramId operation.

Sample request for getMultipleLeadsByProgramId
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "programId":"1003",
    "fields":"lastName,email",
  	"batchSize":"5",
  	"nextPageToken": "PS5VL5WD4UOWGOUCJR6VY7JQOZTXMC7UO74OEIV2HN4NCJZW32AA===="
}
Related Marketo documentation

Delete Lead

The deleteLead operation deletes leads with the given ids.

deleteLead
<marketo.deleteLead>
    <leadIds>{$ctx:leadIds}</leadIds>
</marketo.deleteLead>
properties
  • leadIds: Comma separated list of leads ids.

Sample request

Following is a sample REST/JSON request that can be handled by the deleteLead operation.

Sample request for deleteLead
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "leadIds":"390,392,398"
}
Related Marketo documentation

Describe

The describe operation retrieves all fields and the data type of a lead object.

describe
<marketo.describe/>
Sample request

Following is a sample REST/JSON request that can be handled by the describe operation.

Sample request for describe
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1"
}
Related Marketo documentation

Import Lead

The importLead operation imports leads in bulk.

importLead
<marketo.import>
    <marketoInstanceURL>{$url:marketoInstanceURL}</marketoInstanceURL>
    <accessToken>{$url:accessToken}</accessToken>
    <format>{$url:format}</format>
    <lookupField>{$url:lookupField}</lookupField>
    <listId>{$url:listId}</listId>
    <partitionName>{$url:partitionName}</partitionName>
</marketo.import>
properties
  • marketoInstanceURL: Your marketo instance URL.

  • accessToken: Valid access_token.

  • format: Format of the file to be imported.

  • listId: Marketo Id of the list.

  • lookupField: Attribute to find the duplicate.

  • partitionName: Lead partition name.

Sample request

Following is a sample REST/JSON request that can be handled by the importLead operation.

Sample request for importLead
curl -i -F format=csv -F file=@leads.csv -F access_token=919340b7-2e08-427d-a3cc-67e34b5647bd:sj https://Abc-def-029.mktorest.com/bulk/v1/leads.json
Related Marketo documentation

http://developers.marketo.com/documentation/rest/import-lead/

Get Import Lead Status

The getImportLeadStatus operation retrieves the status of lead operation from ImportLead API call.

getImportLeadStatus
<marketo.getImportLeadStatus>
    <batchId>{$ctx:batchId}</batchId>
</marketo.getImportLeadStatus>
properties
  • batchId: Batch id returned from importLead call.
Sample request

Following is a sample REST/JSON request that can be handled by the getImportLeadStatus operation.

Sample request for getImportLeadStatus
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "batchId":"7"
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-import-lead-status/

Get Import Failure File

The getImportFailureFile operation retrieves of the failure file from a ImportLead Call.

getImportFailureFile
<marketo.getImportFailureFile>
                <batchId>{$ctx:batchId}</batchId>
</marketo.getImportFailureFile>
properties
  • batchId: Batch id returned from importLead call.

Sample request

Following is a sample REST/JSON request that can be handled by the getImportFailureFile operation.

Sample request for getImportFailureFile
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "batchId":"30"
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-import-failure-file/

Get Import Warning File

The getImportWarningFile operation retrieves of the failure file from a ImportLead Call.

getImportWarningFile
<marketo.getImportWarningFile>
                <batchId>{$ctx:batchId}</batchId>
</marketo.getImportWarningFile>
properties
  • batchId: Batch id returned from importLead call.

Sample request

Following is a sample REST/JSON request that can be handled by the getImportWarningFile operation.

Sample request for getImportWarningFile
{
    "marketoInstanceURL":"https://Abc-def-029.mktorest.com",
    "clientSecret":"Vgo6rzIiJyXXXXXXXP3Zr56tK2hv8fJd",
    "clientId":"01f22a42-0f05-4e7f-b675-550b6XXXXXXX1",
    "batchId":"30"
}
Related Marketo documentation

http://developers.marketo.com/documentation/rest/get-import-warning-file/

Sample Configuration

Following is a sample proxy service that illustrates how to connect to Marketo with the init operation and use the getLeadById operation. The sample request for this proxy can be found in   getLeadById sample request. You can use this sample as a template for using other operations in this category.

Sample proxy
	<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="getLeadById"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="marketoInstanceURL" expression="json-eval($.marketoInstanceURL)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="leadId" expression="json-eval($.leadId)"/>
            <property name="fields" expression="json-eval($.fields)"/>

            <marketo.init>
                <marketoInstanceURL>{$ctx:marketoInstanceURL}</marketoInstanceURL>
                <clientId>{$ctx:clientId}</clientId>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
            </marketo.init>

            <marketo.getLeadById>
                <leadId>{$ctx:leadId}</leadId>
                <fields>{$ctx:fields}</fields>
            </marketo.getLeadById>

            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>