Bulk API Object Creation with Associations

Hi All
I am currently using the bulk API to create a custom object (in my case, Location). My question is: Can we associate multiple records (e.g., companies and contacts) with this custom object during the bulk creation process using the batch_api?

In my case, locations are associated with both companies and contacts. I understand that we can use the bulk association API to establish these links, but this requires two separate API calls—one for creating the object and another for creating the associations.

Is there a way to perform both actions (object creation and association) in a single API call, or must they always be done separately?

Thanks in advance for any insights!

Hi @Neel-Tandel,

According to the documentation, this might be possible: Accounts Dashboard | HubSpot

An example there shows that you can add “associations” after “properties” in order to create associations while creating a contact. Obviously you would need to update this according to the structure of your custom object:

///Example request body
{
 "properties": {
 "email": "example@hubspot.com",
 "firstname": "Jane",
 "lastname": "Doe",
 "phone": "(555) 555-5555",
 "company": "HubSpot",
 "website": "hubspot.com",
 "lifecyclestage": "marketingqualifiedlead"
 },
 "associations": [
 {
 "to": {
 "id": 123456
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 279
 }
 ]
 }, 
 {
 "to": {
 "id": 556677
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 197
 }
 ]
 }
 ]
}

Hope this helps!