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 },
{ "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?
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.
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.
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.
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.
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.
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.
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.