associate a company to contact without making it primary

Hi,

im using php SDK to make the association

wherein the $company_id and $contact_id are the actual IDs :

$hubSpot->crm()->companies()->associationsApi()->create($company_id,“contact”,$contact_id,“company_to_contact”);

it works fine, but my problem is, whenever I associate multiple company to the same contact, it makes the last company associated to be the contact’s primary company (which i dont want to).

question:

1. is there a way to make association w/o affecting the primary company of the contact?

2. How do i set the primary company of a contact? (just in case 1 is not possible, and i want to “revert” back the original primary company)

Many thanks

Hey @DBiler ,

I would suggest taking a look at the new v4 endpoints.

If you want to set the company as primary, you would apply the label “Primary” and use the corresponding associationTypeID which in this case should be 1. You can verify that by doing a request for all the labels of the association between Contacts and Companies by hitting this endpoint:

https://api.hubapi.com/crm/v4/associations/contacts/companies/labels

The json you would send to create a company as the primary would look like this:

[
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 1,
 "label": "Primary"
 }
]

If you did not want to set the label to primary, it would look like this:

[
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 279
 }
]

And if you have created new labels, the associationCategory would be USER_DEFINED and the ID would need to be collected with the previously mentioned request.

@dennisedson I have the “opposite” problem, perhaps you have some thouhts?

https://community.hubspot.com/t5/APIs-Integrations/Create-Primary-Contact-Association/m-p/771638#M62429

Thanks!

I have used V4 association API to create association from Company to contact. with the following body. but still it is creating the primary contact. I want to create a association with out making it a primary contact.

[
{
“associationCategory”: “HUBSPOT_DEFINED”,
“associationTypeId”: 280
}
]