Fewest calls to get closed company deals

What would be the fewest amount of api endpoints i’d need to call to get a list of company deals that have gotten to a particular dealstage if i have the company id already. Preferably with the ability to limit the amount returned as well and sort them.
At present it looks like i’d have to use the company assocations endpoint to get a list of deals and then the deals read or search endpoint and then filter them in code.
Is there a better way then this?

Hey @aasmith,

You could do this using the CRM Search API. For instance the request below would return all of the deals associated to a specific company that has a stage of “X”. You can also sort and limit as needed.

curl --location --request POST 'https://api.hubapi.com/crm/v3/objects/deals/search' \
--header 'Authorization: Bearer {{access_token}} \
--header 'Content-Type: application/json' \
--data-raw '{
 "properties": [ "dealname", "dealstage" ],
 "filters": [
 {
 "propertyName": "associations.company",
 "operator": "EQ",
 "value": "6055340226"
 },
 {
 "propertyName": "dealstage",
 "operator": "EQ",
 "value": "X"
 }
 ]
 }

There are a few nuances to be aware of with this endpoint, all covered in the documentation but basically keep in mind that:

  • It may take a few moments for newly created or updated CRM objects to show up in search results.
    Archived CRM objects won’t appear in any search results.
  • The search endpoints are rate limited to four requests per second.
  • The search endpoints are limited to 10,000 total results for any given query. Attempting to page beyond 10,000 will result in a 400 error.
  • When searching for phone numbers, HubSpot uses special calculated properties to standardize the format. These properties all start with hs_searchable_calculated_*. As a part of this standardization, HubSpot only uses the area code and local number. You should refrain from including the country code in your search or filter criteria.

Hope that helps!

That looks like it does what i want thanks. Didn’t realise you could link straight through to the associations.