APIs & Integrations

hubsp
Contributeur

API Create contact belonging to a Company

Résolue

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 Votes
1 Solution acceptée
Willson
Solution
HubSpot Employee
HubSpot Employee

API Create contact belonging to a Company

Résolue

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

Voir la solution dans l'envoi d'origine

1 Réponse
Willson
Solution
HubSpot Employee
HubSpot Employee

API Create contact belonging to a Company

Résolue

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