I’m new to the community, just getting started with Hubspot.
We are creating a custom integration in which I need to retrieve all the contacts belonging to a “Contacts List”, with their companies, like:
- firstname
- lastname
- email
- company name
- company website
I’m using the “Contacts List API V1” with no problem, but I can’t get the associated properties from the Company.
I read somewhere that we have access to those associated properties in the CRM Search, so I’m grabbing all the emails I get from the first response and now querying the Search API V3, with a “email IN […]” filter, like this:
Call the “Get contacts in a list” endpoint, while using an instance of the “property” query parameter to retrieve the given Contacts’ "associatedcompanyid" property value (this is a hidden Contact property, which you may not have come across yet). Your request URL should look something like this:
You should then have all Company record IDs relevant to the given Contacts.
Request 2
Call the “Read a batch of companies” endpoint, specifying the Company IDs and the properties to be returned in the request body. Your request body might look something like this
(substitute the placeholders with your target Company properties)
Yes, the associatedcompanyid will reflect the Company that is marked as the “Primary” association. The property description provided by HubSpot is: “HubSpot defined ID of a contact’s primary associated company in HubSpot.”