APIs & Integrations

PWatt6
Member

Search for records on associated property

SOLVE

Doing some investigation and I'm wondering if there is a way to use the search API for a record using an associated objects property?

 

Fore example, I want to search for contacts that are associated to Companies where [CompanyProperty]= X

 

We have a list of companies and ideally only want to return contacts, deals, etc that are assocaited to that list of companies. I know we can search by CompanyID, but was hoping to search by a different Property. 

0 Upvotes
2 Accepted solutions
Jaycee_Lewis
Solution
Community Manager
Community Manager

Search for records on associated property

SOLVE

Hi, @PWatt6 👋 Thanks for reaching out. Look at past threads such as this one and this reply from @Teun, this will likely require two calls. Hey @nikodev, have you come across any workarounds for what @PWatt6 is describing?

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
nikodev
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Search for records on associated property

SOLVE

Hey @PWatt6,

I think @Jaycee_Lewis is correct. I recommend going with one of the solutions offered in the 2 posts she linked to. 

For a little extra feedback - it obviously depends on your specific use case, but if you have a long list of Companies with many different values you would need to search by, I'd probably use the Company batch read endpoint to return all Companies, ensuring you include the property you can identify the ones you want by via the "properties" parameter, and then filtering that down programmatically, so you have the IDs of all of the appropriate Companies. 

At this point, depending on the amount of objects you're working with, I'd either use the v4 batch associations endpoint to retrieve all associated Deals, and then Contacts (1 request per object Type + paging). It's in the Association Schema Endpoints tab at the bottom. 

Or - I'd use the Company read endpoint. Ensuring to add the associated object types you want to retrieve the IDs for in the "associations" parameter. This would would require a lot more requests, since you'd have to do 1 per Company. But you'd get both the associated Deal and Contact, per Company. 

Happy to help if you have any more specific questions. Good luck. 

A8 Labs

View solution in original post

2 Replies 2
nikodev
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Search for records on associated property

SOLVE

Hey @PWatt6,

I think @Jaycee_Lewis is correct. I recommend going with one of the solutions offered in the 2 posts she linked to. 

For a little extra feedback - it obviously depends on your specific use case, but if you have a long list of Companies with many different values you would need to search by, I'd probably use the Company batch read endpoint to return all Companies, ensuring you include the property you can identify the ones you want by via the "properties" parameter, and then filtering that down programmatically, so you have the IDs of all of the appropriate Companies. 

At this point, depending on the amount of objects you're working with, I'd either use the v4 batch associations endpoint to retrieve all associated Deals, and then Contacts (1 request per object Type + paging). It's in the Association Schema Endpoints tab at the bottom. 

Or - I'd use the Company read endpoint. Ensuring to add the associated object types you want to retrieve the IDs for in the "associations" parameter. This would would require a lot more requests, since you'd have to do 1 per Company. But you'd get both the associated Deal and Contact, per Company. 

Happy to help if you have any more specific questions. Good luck. 

A8 Labs

Jaycee_Lewis
Solution
Community Manager
Community Manager

Search for records on associated property

SOLVE

Hi, @PWatt6 👋 Thanks for reaching out. Look at past threads such as this one and this reply from @Teun, this will likely require two calls. Hey @nikodev, have you come across any workarounds for what @PWatt6 is describing?

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes