APIs & Integrations

hubsp
Mitwirkender/Mitwirkende

API Create contact belonging to a Company

lösung

Hi

 

When creating new contacts by the api, I also need to set some kind of relation between the contact and company the contact belongs to, right? The contact should have something like a CompanyId or something. What property sets that relation?

0 Upvotes
1 Akzeptierte Lösung
Willson
Lösung
HubSpot Employee
HubSpot Employee

API Create contact belonging to a Company

lösung

Hi @hubsp 

 

This association is done using our CRM Associations API found here: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

 

As you can see in the documentation, this API allows you to create associations between objects and in this specific case, we'd be looking at the following:

Request URL:

PUT https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Sample Body:

{
  "fromObjectId": CONTACT_ID,
  "toObjectId": COMPANY_ID,
  "category": "HUBSPOT_DEFINED",
  "definitionId": 1
}

Once this is done, we'll see that the Contact is correctly associated based on the above request. 

 

I hope this helps!

Product Manager @ HubSpot

Lösung in ursprünglichem Beitrag anzeigen

1 Antwort
Willson
Lösung
HubSpot Employee
HubSpot Employee

API Create contact belonging to a Company

lösung

Hi @hubsp 

 

This association is done using our CRM Associations API found here: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

 

As you can see in the documentation, this API allows you to create associations between objects and in this specific case, we'd be looking at the following:

Request URL:

PUT https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Sample Body:

{
  "fromObjectId": CONTACT_ID,
  "toObjectId": COMPANY_ID,
  "category": "HUBSPOT_DEFINED",
  "definitionId": 1
}

Once this is done, we'll see that the Contact is correctly associated based on the above request. 

 

I hope this helps!

Product Manager @ HubSpot