OwenL
August 15, 2024, 3:42am
1
I’'m looking for API documentation for retrieving specific contact details using the company ID?
I’m aiming to get all the contacts associated with the company ID returned in an array format, including their details (job title, email, etc.).
So far, I’m only getting a return of an array of “object IDs” for contacts associated with the company.
Hi @OwenL ,
Have you tried using the Search endpoint (/crm/v3/objects/contacts/search) in the CRM/Contacts API ?
The request would look something like this:
{
"filters": [
{
"value": "{{ company_ID }}",
"propertyName": "associations.company",
"operator": "EQ"
}
],
"properties": ["firstname", "lastname", "email", "jobtitle"]
}
Obviously, you would replace the {{ company_ID }} with the ID of the company you would like to retrieve the contacts for and it should retrieve a list of contacts associated with that company.
Then in the “properties” array you can specify which properties you would like to retrieve for those contacts.
Hope this helps!
OwenL
August 15, 2024, 12:59pm
3
I’m getting back an error of:
Failed to parse body input
@OwenL - must have something to do with how you are passing in that data into the API call.
Here is a setup that definitely works when using node js:
const searchData = {
"filterGroups":[
{
"filters":[
{
"propertyName": "associations.company",
"operator": "EQ",
"value": "1234567890"
}
]
}
],
"properties": ["firstname","lastname"]
}
const apiResponse = await hubspotClient.crm.contacts.searchApi.doSearch(searchData);
console.log(JSON.stringify(apiResponse, null, 2));
More examples of how this can be set up:
Accounts Dashboard | HubSpot (Endpoints > Search)
If you want to share your code we can also take a look into that.