Marketo REST API: Associating a lead with a program

345 Views Asked by At

I've searched high and low and don't believe this is possible, but before giving up, thought I'd ask on here. Is there any way that anyone's found - roundabout or not - to create a lead and associate it with a program in Marketo via their REST API?

Thanks!

2

There are 2 best solutions below

0
On
   curl -X POST \
  "${baseUrl}rest/v1/leads.json?access_token=${AccessToken}" \
  -H "Content-Type: application/json" \
  -d '
{  
   "action":"createOrUpdate",
   "lookupField":"email",
   "input":[  
      {  
         "email":"[email protected]",
         "firstName":"Sergejs",
         "lastName":"test"
      },
      {  
         "email":"[email protected]",
         "firstName":"Sergejs",
         "lastName":"test1"
      },
      {  
         "email":"[email protected]",
         "firstName":"Sergejs",
         "lastName":"test2"
      }]
    }
   '

LeadId=$(curl -X GET "${baseUrl}rest/v1/leads.json?access_token=${AccessToken}&filterType=email&filterValues=${leademail}" | jq '.result | .[].id')

curl -X POST "${baseUrl}rest/v1/leads/programs/${NewProgramId}/status.json?access_token=${AccessToken}" \
  -H "Content-Type: application/json" \
  -d " {
    \"status\": \"Registered\",
    \"input\": [
        {\"id\": ${LeadId} }
    ]
}
"
0
On

Why not using a smart campaign that automatically associate leads with the relevant program?

You can create some custom field in MLM (for example: "Associate with Program") and when you create a new lead with the API add some value in this field, i.e "associateWithProgram" : "program123".

Then, in MLM create a campaign that is being triggered whenever a new lead is created and the associateWithProgram field is not empty.

The flow will be to add the lead to the desired program.