APIs & Integrations

KimS
Member

Filter read contacts on custom field

SOLVE

Hello,

I need to query contacts that have a specific custom field filled. How can I do this?

I found this in the documentation ( https://developers.hubspot.com/docs/api/crm/contacts ) but it's not clear what each field is for

 

 

 

curl --request POST \
  --url 'https://api.hubapi.com/crm/v3/objects/contacts/batch/read?archived=false' \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "properties": [
    "string"
  ],
  "propertiesWithHistory": [
    "string"
  ],
  "idProperty": "string",
  "inputs": [
    {
      "id": "string"
    }
  ]
}'

 

 

 

Thank you

0 Upvotes
1 Accepted solution
bohart
Solution
Participant

Filter read contacts on custom field

SOLVE

Hi @KimS,

You can use `/crm/v3/objects/contact/search` endpoint instead (to search contacts by any of their properties). It should be more understandable. Here is a callback example:

curl 'https://api.hubapi.com/crm/v3/objects/contact/search' \
  -H 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'content-type: application/json' \
  --data '{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "PROPERTY_NAME_TO_FILTER/SEARCH",
          "operator": "EQ",
          "value": "YOUR_VALUE_TO_SEARCH_IN_THE_PROPERTY"
        }
      ]
    }
  ],
  "properties": [
    "property_name1_to_include_in_the_results_for_all_found_contacts",
    "property_name2_to_include_in_the_results_for_all_found_contacts"
  ],
  "limit": 10
}'

 

View solution in original post

0 Upvotes
3 Replies 3
bohart
Solution
Participant

Filter read contacts on custom field

SOLVE

Hi @KimS,

You can use `/crm/v3/objects/contact/search` endpoint instead (to search contacts by any of their properties). It should be more understandable. Here is a callback example:

curl 'https://api.hubapi.com/crm/v3/objects/contact/search' \
  -H 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'content-type: application/json' \
  --data '{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "PROPERTY_NAME_TO_FILTER/SEARCH",
          "operator": "EQ",
          "value": "YOUR_VALUE_TO_SEARCH_IN_THE_PROPERTY"
        }
      ]
    }
  ],
  "properties": [
    "property_name1_to_include_in_the_results_for_all_found_contacts",
    "property_name2_to_include_in_the_results_for_all_found_contacts"
  ],
  "limit": 10
}'

 

0 Upvotes
KimS
Member

Filter read contacts on custom field

SOLVE

Actually, what about paging there?
I did a test with limit = 1 (had only 2 items with said field)

And it returns 

"paging":{"next":{"after":"1"}}}

what is the next call to make for next page then?

0 Upvotes
KimS
Member

Filter read contacts on custom field

SOLVE

Thank you very much, works like a charm.

0 Upvotes