APIs & Integrations

ruben_mejiatpm
Member

Validate if a lead exists in a list

I have a form where I have to check if the email exists in the Hubspot database in a list.

 

Is there an endpoint to verify this information and to be able to do the validation by AJAX or similar?

2 Replies 2
webdew
Guide | Diamond Partner
Guide | Diamond Partner

Validate if a lead exists in a list

Hi @ruben_mejiatpm ,

For fetching existing contacts use below curl

<?php
$data = '{
"filterGroups":[
{
"filters":[
{
"propertyName": "firstname",
"operator": "EQ",
"value": "Alice"
}
]
}
]
}';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);


Also take this documentation link for other existing objects.
https://developers.hubspot.com/docs/api/crm/search

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 Upvotes
himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Validate if a lead exists in a list

Hello @ruben_mejiatpm,

 

Yes, there is an API (https://api.hubapi.com/contacts/v1/lists/LISTID/contacts/all?hapikey=demo), you can get this API over here:

 

https://legacydocs.hubspot.com/docs/methods/lists/get_list_contacts, through which you can get the list in which you want to search the email, and then all the contacts will be fetched from that list. Then, you can parse that response and you will be able to do the validation if that email is present in the HubSpot list or not.

 

Regards,

Digital Marketing & Inbound Expert In Growth Hacking Technology