When using the Get all companies API, include the &properties=num_associated_deals property so that the return results will include the value of the number of associated deals for the companies record. If there’s no associated deals, the value will be “”.
Knowning this, you can loop through the return results and only retrieve the companyId that has num_associated_dealsvalue known.
Next, include the companyId retrieved in our earlier steps and include it on the url of Get associations for CRM object API with a definition id of 6 (Association definition); this will retrieve all the dealId for that particular company record.
Currently, it is not possible to get multiple companies record by companyIds.
I have a similar issue where I am trying to retrieve the company ids via the get all companies endpoint. But I am getting an error everytime I try. The json response for the company Id is below (sensitive data removed off course):
It looks like the internal id for the company id property is hs_object_id(Settings > Properties > Company properties > Search for ‘Company ID’ > Click in > Check the internal name)
This is likely why when you use companyId to store the var companyId property, it is throwing an error.