APIs & Integrations

idunskiy
Participant

Get company id for every deal

Please advise - I need to get the associated companies' IDs for chosen deals.
Here is the URL:
 

 

POST https://api.hubapi.com/crm/v3/objects/deals/search

And the body:
filters = [
{ "propertyName": "dealstage", 
  "operator": "IN", 
  "values": stage_ids }
] 

if owner_ids: 
filters.append(
{ "propertyName": "hubspot_owner_id", 
"operator": "IN", 
"values": owner_ids 
}) 

payload = 
{ 
"filterGroups": 
[{ "filters": filters }], 
"properties": 
["dealstage", "dealname", "pipeline", "associatedCompanyId"], 
"associations": ["company"] 
}

And in the response, I don't receive associatedCompanyId or other information about the company.

 

I know that I can use Associations API to get company info like this:

url = f"https://api.hubapi.com/crm/v3/objects/deals/{deal_id}/associations/company

But in this case, I'd need to do it for every deal, which I don't want to do. Please advise.

 

0 Upvotes
3 Replies 3
Jaycee_Lewis
Community Manager
Community Manager

Get company id for every deal

Hey, @Teun 👋 Great point. The issue here is, this customer doesn't have either of those subscriptions. — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Get company id for every deal

Hi, @idunskiy 👋 You are correct about the limitations of the Search API. You'll have to make a second request to the Associations API to get what you are after. Unfortunately, there is not a unified endpoint that will do everything you want in a single call.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Get company id for every deal

Unless you create a GraphQL query 🎉

Here is a great blog from Carter: https://developers.hubspot.com/blog/reducing-hubspot-requests-utilizing-batch-api-and-graphql-for-be...

 

It is limited to Sales/Service Hub Enterprise or Content Hub Pro.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes