Pardot API: Add new prospect to certain list

1.1k Views Asked by At
$prospectData = array(
                'user_key' => $user_key,
                'api_key' => $api_key,
                'first_name' => $firstName,
                'last_name' => $lastName,
                'city'  => $city,
                'state' => $state,
                'comments'  => $comments
            );

            callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/create/email/'.$email, $prospectData);

I'm able to create a new prospect with a form that I have. It inserts all the data I supplied it (name, city, state, etc), but I need to also add this prospect to a list.

I tried adding to my $prospectData things like list => '1234' or "list_id" => '1234', but that doesn't seem to be working.

Is this possible to do? I know I can assign a prospect to a list via another api route using their ID, but I need this prospect to be added immediately upon form submit

1

There are 1 best solutions below

0
On

Well it's not exactly ideal, but I had to do a new api call after creating the user.

$addprospect = callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/create/email/'.$email, $prospectData);

            $addprospectxml = new SimpleXMLElement($addprospect);
            $id = $addprospectxml->prospect->id;

            $listData = array(
                'user_key' => $user_key,
                'api_key' => $api_key,
                'list_32106' => "1"
            );

            $updateProspect = callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/update/id/'.(String)$id[0], $listData);

When creating a prospect, it will return XML with the newly crated prospect's ID. that ID can be used in a new api update call where you can set the list.