https://api.hubapi.com/crm/v3/objects/contacts/search filter by email

Hi all,

Im trying to pass a email filter using the new v3 search like so:

{
 "filterGroups": [
 {
 "filters": [
 {
 "value": "emailmaria@hubspot.com",
 "propertyName": "email",
 "operator": "EQ"
 }
 ]
 }
 ],
 "sorts": [
 "createdate"
 ],
 "properties": [
 "email,firstname,lastname,createdate"
 ],
 "limit": 10,
 "after": 1
}

and I have a contact with email “emailmaria@hubspot.com”, but I’m not getting the data in the response.

Response:

{
 "total": 1,
 "results": []
}

Hi @PramodJ ,
Hope this will help for you.
Please use below php code, which is working fine at our end.
<?php
$data = ‘{
“filterGroups”: [
{
“filters”: [
{
“value”: “emailmaria@hubspot.com”,
“propertyName”: “email”,
“operator”: “EQ”
}
]
}
],
“properties”: [
“email,firstname,lastname,createdate”
]
}’;
$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);

Hope this helps!

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

Hey @webdew,

This works, the problem with my json request body was, there is 1 entry with that email and I had a non-zero value for after field in the request body.

Thanks for the help!