Lead to Primary Company Association - Creating leads via the API
SOLVE
Hi,
I need to bulk import some leads into HubSpot as part of moving over our B2B sales team. There is no import option on the front end so I'm looking to sort this via the API.
I've got a script setup to loop through some names etc and I have the company_id for each lead I want to create. So far, my main function is as follows.
The association I'm using is the only reference I can find in the docs for Lead-to-Object and is for the lead-to-company association. However, when this runs, I'm getting the error:
Status Code: 400, Response: {"status":"error","message":"A LEAD_TO_PRIMARY_CONTACT or LEAD_TO_PRIMARY_COMPANY association is required to create a LEAD object.","correlationId":"dc9bd360-d52f-4a8a-b692-0394a6b5d427","category":"VALIDATION_ERROR"}
I can't find any reference to LEAD_TO_PRIMARY_COMPANY in the docs or in the admin/ setting pages in our HubSpot so really at a loss on how to solve.
Lead to Primary Company Association - Creating leads via the API
SOLVE
@SLearIt looks like HubSpot requires a specific "LEAD_TO_PRIMARY_COMPANY" association to create a lead via the API. The associationTypeId you’re using (610) might not match this requirement.
Try replacing associationTypeId: 610 with the correct ID for LEAD_TO_PRIMARY_COMPANY. Unfortunately, HubSpot doesn’t always document these IDs clearly. You might need to retrieve the association types via the API (/crm/v4/associations) to confirm the correct ID.
Another option is to contact HubSpot support to confirm the exact association ID needed for "LEAD_TO_PRIMARY_COMPANY."
Lead to Primary Company Association - Creating leads via the API
SOLVE
@SLearIt looks like HubSpot requires a specific "LEAD_TO_PRIMARY_COMPANY" association to create a lead via the API. The associationTypeId you’re using (610) might not match this requirement.
Try replacing associationTypeId: 610 with the correct ID for LEAD_TO_PRIMARY_COMPANY. Unfortunately, HubSpot doesn’t always document these IDs clearly. You might need to retrieve the association types via the API (/crm/v4/associations) to confirm the correct ID.
Another option is to contact HubSpot support to confirm the exact association ID needed for "LEAD_TO_PRIMARY_COMPANY."