APIs & Integrations

vikram-mit
Participant

How to get contact associated to a company using APIs

SOLVE

I am using company api as 

 

https://api.hubapi.com/crm/v3/properties/companies

 

This gives me basic info of the comapnies.  How do i get the primary contact associated with the company?  I looked into properties= option but didn't find any property that indicates the contact details associated the company. 

1 Accepted solution
tominal
Solution
Guide | Partner
Guide | Partner

How to get contact associated to a company using APIs

SOLVE
If we're both talking about a Company to Contact Record within HubSpot then yes.

However, you could also create your own custom company properties that include the primary contact's information i.e. firstname, email, phone, etc.
After you create those, you fill them out over the API, a workflow, or the UI when you create the company record. There are several ways to accomplish what you're looking for.

Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com

View solution in original post

7 Replies 7
jamieroyce-mc
Contributor

How to get contact associated to a company using APIs

SOLVE

Exactly my same question!

0 Upvotes
tominal
Solution
Guide | Partner
Guide | Partner

How to get contact associated to a company using APIs

SOLVE
If we're both talking about a Company to Contact Record within HubSpot then yes.

However, you could also create your own custom company properties that include the primary contact's information i.e. firstname, email, phone, etc.
After you create those, you fill them out over the API, a workflow, or the UI when you create the company record. There are several ways to accomplish what you're looking for.

Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com
vikram-mit
Participant

How to get contact associated to a company using APIs

SOLVE

but none is out of the box. Correct? 

 

And in case i go with out of the box then what i described in terms of number of calls required is correct as well? 

tominal
Guide | Partner
Guide | Partner

How to get contact associated to a company using APIs

SOLVE

As far as I know there is no "eager loading" of the contact from a company record. Maybe something exists but I doubt it.

Via the HubSpot API, you could make an API request to the company to get the contact ID, then another to get the contact details.

Hope that helps.


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com
tominal
Guide | Partner
Guide | Partner

How to get contact associated to a company using APIs

SOLVE

Hi Vikram,

Try reading through the endpoint documentation here: https://developers.hubspot.com/docs/api/crm/companies

"List associations of a company by type" will get you the records associated with that company.
GET /crm/v3/objects/companies/{companyId}/associations/{toObjectType}

"Associate a company with another object" will allow you to make the association to a contact.
PUT /crm/v3/objects/companies/{companyId}/associations/{toObjectType}/{toObjectId}/{associationType}




Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com
vikram-mit
Participant

How to get contact associated to a company using APIs

SOLVE

so even the fundamental info about a company like primary contact needs association calls? 

 

Further, trying out like: https://api.hubapi.com/crm/v3/objects/companies/2220312904/associations/contacts

gives me result:
{
"results": [
{
"id": "101",
"type": "company_to_contact"
},
{
"id": "401",
"type": "company_to_contact"
},
{
"id": "3152",
"type": "company_to_contact"
}
]
}

 

Now, it seems i need to make one more call to get contact. So, 2 additional calls just to get contact. Further, 3 are returned and i don't know which one is main. Do i need to make call to each of these to find the info?

 

jamieroyce-mc
Contributor

How to get contact associated to a company using APIs

SOLVE

Did you resolve the best way to get the primary contact for a company? I'm following down this same path now and it would be great if the company object had a "primary contact id" at least. 

0 Upvotes