HubSpot CRM: Using IN operator for company search with custom property

I’ve created a custom property for companies in HubSpot called customer_identifier. We need to find companies that match any of several identifiers. I’m using the IN operator in the HubSpot API, but it’s not working as expected.

When I include multiple values in the search, like this:

{
  "filterGroups": [{
    "filters": [{
      "propertyName": "customer_identifier",
      "operator": "IN",
      "values": ["ABC123", "XYZ789", "DEF456"]
    }]
  }],
  "properties": ["customer_identifier"]
}

It doesn’t return any results, even though one of the values exists. But if I search with just the existing value, it works fine.

Is this how the HubSpot API is supposed to work? I thought it would return matches for existing values and ignore the rest. Am I missing something here?

yo, i’ve run into this too. the IN operator can be a real pain sometimes. have u tried using the CONTAINS_TOKEN operator instead? it’s worked for me before. just separate ur values with spaces like this:

"operator": "CONTAINS_TOKEN",
"value": "ABC123 XYZ789 DEF456"

might be worth a shot if nothing else is working

I’ve encountered a similar issue with custom properties and the IN operator in HubSpot. From my experience, the behavior you’re seeing is indeed unexpected, but there’s a workaround.

Instead of using the IN operator, I’ve had success using multiple OR conditions. It’s a bit more verbose, but it gets the job done. Here’s how I structure my query:

{
  "filterGroups": [{
    "filters": [
      {"propertyName": "customer_identifier", "operator": "EQ", "value": "ABC123"},
      {"propertyName": "customer_identifier", "operator": "EQ", "value": "XYZ789"},
      {"propertyName": "customer_identifier", "operator": "EQ", "value": "DEF456"}
    ]
  }],
  "properties": ["customer_identifier"]
}

This approach has consistently returned the expected results for me. It’s not as elegant as using IN, but it’s reliable. You might want to consider submitting a support ticket to HubSpot about the IN operator behavior, as it could be a bug in their API.

Having worked extensively with HubSpot’s API, I can confirm that the IN operator can be finicky, especially with custom properties. One thing I’ve found helpful is to double-check the exact format of the custom property values. Sometimes, there might be hidden spaces or slight differences in formatting that can throw off the search.

Another approach that’s worked for me is using the CONTAINS_TOKEN operator instead of IN. It’s a bit more flexible and can often catch matches that IN misses. Your query might look like this:

{
  "filterGroups": [{
    "filters": [{
      "propertyName": "customer_identifier",
      "operator": "CONTAINS_TOKEN",
      "value": "ABC123 XYZ789 DEF456"
    }]
  }],
  "properties": ["customer_identifier"]
}

This method has been more reliable in my experience, though it’s worth noting that it might return partial matches as well. Always good to test thoroughly with your specific data set.