You can use SOAP API syncLead or syncMultipleLeads functions to insert or update (upsert) lead records in Marketo. When updating an existing lead, the lead can be identified by Marketo ID, Marketo Cookie or Email.
If any of these attributes are set as a part of the input parameter and if there is a matching lead in Marketo with these values, the existing lead record will be updated instead of created. Passing the Marketo cookie id as an input parameter helps in associating the new lead with existing anonymous activity records.
When Marketo workspaces are enabled and the header is used, the following rules are applied:
- New leads are created in the primary partition of the named workspace.
- Leads matched by the Marketo Lead ID, a foreign system ID, or a Marketo cookie, must exist in the primary partition of the named workspace, otherwise an error will be returned.
- If an existing lead is matched by email, the named workspace is ignored and the lead is updated in its current partition.
syncMultipleLeads allows to turn off the dedup feature. If dedupEnabled is set to true and no other unique identifier is given (foreignSysPersonId or Marketo lead Id), then the lead record will be de-duplicated using the email address. Keep in mind, passing in 'false' will create duplicates within Marketo.
I tend to use syncMultipleLeads regardless I am sending one or many, making the API call more portable.
The skeleton is :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
<soapenv:Header>
<mkt:AuthenticationHeader>
<mktowsUserId>?</mktowsUserId>
<requestSignature>?</requestSignature>
<requestTimestamp>?</requestTimestamp>
<!--Optional:-->
<audit>?</audit>
<!--Optional:-->
<mode>?</mode>
</mkt:AuthenticationHeader>
</soapenv:Header>
<soapenv:Body>
<mkt:paramsSyncMultipleLeads>
<leadRecordList>
<!--Zero or more repetitions:-->
<leadRecord>
<!--Optional:-->
<Id>?</Id>
<!--Optional:-->
<Email>?</Email>
<!--Optional:-->
<ForeignSysPersonId>?</ForeignSysPersonId>
<!--Optional:-->
<ForeignSysType>?</ForeignSysType>
<!--Optional:-->
<leadAttributeList>
<!--Zero or more repetitions:-->
<attribute>
<attrName>?</attrName>
<!--Optional:-->
<attrType>?</attrType>
<attrValue>?</attrValue>
</attribute>
</leadAttributeList>
</leadRecord>
</leadRecordList>
<!--Optional:-->
<dedupEnabled>?</dedupEnabled>
</mkt:paramsSyncMultipleLeads>
</soapenv:Body>
</soapenv:Envelope>