APIs & Integrations

GDiMaiolo
Top Contributor

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

 

I’m using the following endpoint to create associations between objects:

 

ruby
CopierModifier
https://api.hubapi.com/crm/v4/associations/deals/companies/batch/create

 

I’m trying to associate deals to companies, but instead of using the internal hs_company_id, I would like to use a custom unique property (e.g. code_client) to identify the company.

It seemed to me that this was possible using idProperty, but after several attempts, I haven’t been able to make it work. I’ve double-checked that the property is correctly defined as unique and the values are correct.

Here is an example of the payload I’m using:

 

 
{ "from": { "id": deal_id },
"to": { "id": comp_id, "idProperty": "code_client" // ← the exact name of the unique property in HubSpot },
"types": [{ "associationCategory": "HUBSPOT_DEFINED", "associationTypeId": ASSOC_TYPE_ID }] }

 

But I get this response:


{ "status": "COMPLETE", "results": [], "numErrors": 1, "errors": [{ "status": "error", "category": "VALIDATION_ERROR", "message": "COMPANY=111111 is not valid" }] }

 

Any idea if idProperty is supported in this context, or if there’s another way to associate records using a unique property other than the internal ID?

Thanks in advance! 🙏

0 Upvotes
2 Accepted solutions
ArisudanTiwari
Solution
Guide | Gold Partner
Guide | Gold Partner

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

Hello @GDiMaiolo ,

Unfortunately, the idProperty field isn't supported in the HubSpot Associations API. So, you can’t directly associate a deal with a company using a custom property like code_client.

Check similar community thread - https://community.hubspot.com/t5/APIs-Integrations/Is-it-possible-to-associate-an-object-using-a-cus...

What you should do instead -
Use the Search API to look up the company’s internal ID (hs_object_id) based on code_client.
Example:
GET /crm/v3/objects/companies/search

And then use that internal ID in your association request with:
POST /crm/v4/associations/deals/companies/batch/create

This is currently the only supported way to associate objects when working with custom properties.

Helpful links-

Search API guide - https://developers.hubspot.com/docs/guides/api/crm/search

Associations v4 API docs - https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4

CRM Batch Read Companies (v3) - https://developers.hubspot.com/docs/reference/api/crm/objects/companies

Hope this clears it up!

If my reply answered your question, please mark it as a solution to make it easier for others to find.


Cheers!

Arisudan Tiwari
HubSpot Advisor



Grazitti

View solution in original post

GDiMaiolo
Solution
Top Contributor

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

Hello,

 

Thanks to both of you for the clear and detailed response. I was specifically trying to avoid having to perform a search in order to limit the number of API calls.
It’s unfortunate that it's not possible to create associations between objects using anything other than the primary internal ID.

Thanks again for your help! 

 

regards,

Guillaume

View solution in original post

3 Replies 3
GDiMaiolo
Solution
Top Contributor

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

Hello,

 

Thanks to both of you for the clear and detailed response. I was specifically trying to avoid having to perform a search in order to limit the number of API calls.
It’s unfortunate that it's not possible to create associations between objects using anything other than the primary internal ID.

Thanks again for your help! 

 

regards,

Guillaume

ArisudanTiwari
Solution
Guide | Gold Partner
Guide | Gold Partner

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

Hello @GDiMaiolo ,

Unfortunately, the idProperty field isn't supported in the HubSpot Associations API. So, you can’t directly associate a deal with a company using a custom property like code_client.

Check similar community thread - https://community.hubspot.com/t5/APIs-Integrations/Is-it-possible-to-associate-an-object-using-a-cus...

What you should do instead -
Use the Search API to look up the company’s internal ID (hs_object_id) based on code_client.
Example:
GET /crm/v3/objects/companies/search

And then use that internal ID in your association request with:
POST /crm/v4/associations/deals/companies/batch/create

This is currently the only supported way to associate objects when working with custom properties.

Helpful links-

Search API guide - https://developers.hubspot.com/docs/guides/api/crm/search

Associations v4 API docs - https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4

CRM Batch Read Companies (v3) - https://developers.hubspot.com/docs/reference/api/crm/objects/companies

Hope this clears it up!

If my reply answered your question, please mark it as a solution to make it easier for others to find.


Cheers!

Arisudan Tiwari
HubSpot Advisor



Grazitti

kosalaindrasiri
Top Contributor | Partner
Top Contributor | Partner

Associate deal to company using unique property (not hs_company_id) via API v4

SOLVE

Hey @GDiMaiolo,

 

To my knowledge, the /crm/v4/associations API does not support custom ID properties. It only works with internal HubSpot IDs (hs_object_id).

 

Suppose you want to associate a deal to a company using a custom unique property like code_client. In that case, you may be able to first look up the company’s internal ID using the Search API, then use that ID in your association call.

Refer:

 

Hope this might be a help!

 

Regards,

Kosala Indrasiri

CEO

Sanmark Solutions
Linkedin
Kosala Indrasiri
emailAddress
kosala@thesanmark.com
website
www.sanmarksolutions.com
linkedinwhatsapp
Book a Consultation

Did my post help answer your question? Mark this as a solution.

0 Upvotes