Search contacts by email domain not working properly

Hello!
I’m using the v3 API to search contacts by email domain. I’m following the docs Search the CRM - HubSpot docs but the wildcard search is returning more results than it should.

For example, I created 2 contacts on my Hubspot account with the following emails: "gmail.com@fake.co" and “fake.co@gmail.com” and I’m using the following request body:

{
 "filterGroups": [
 {
 "filters": [
 {
 "operator": "CONTAINS_TOKEN",
 "propertyName": "email",
 "value": "*@fake.co"
 }
 ]
 }
 ]
}

This is returning both contacts, but I believe it should return only one (gmail.com@fake.co). If I use “*@gmail.com” both contacts are still returned. I also tried “*@gmail.com” but it also returns both contacts.
So I believe the wildcard search is not working properly, as it’s ignoring the “@”.
How can I properly search by email domains using the API?
Tank you

Hi @daniloaf,

I am also experiencing the same behaviour. It looks like HubSpot is ignoring the “@” and returning any contacts with an email containing the search term before (or after) the “@” symbol.

This appears to be a bug that HubSpot will need to address as this contradicts what is documented here.

@daniloaf - would it be simpler for your case to filter on the Email domain property ‘hs_email_domain’ rather than the raw email?

Steve

Thanks, Steve. That works, but as I’m using a 3rd Party API to connect to Hubspot I cannot simply use it forever, but would be a temporary solution for me.
This seems to be a bug on Hubspot API anyway so I hope they fix this soon.