API Create contact belonging to a Company

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?

Hi @hubsp

This association is done using our CRM Associations API found here: Accounts Dashboard | HubSpot

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!