# Bulk API Object Creation with Associations

**URL:** <https://community.hubspot.com/t/bulk-api-object-creation-with-associations/118536>\
**Category:** APIs & Integrations\
**Tags:** api\
**Created:** [October 17, 2024, 12:45am UTC](https://community.hubspot.com/t/bulk-api-object-creation-with-associations/118536 "2024-10-17T00:45:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neel-Tandel](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@Neel-Tandel](https://community.hubspot.com/u/Neel-Tandel)\
**Post date:** [October 17, 2024, 12:45am UTC](https://community.hubspot.com/t/bulk-api-object-creation-with-associations/118536/1 "2024-10-17T00:45:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![evaldas](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/evaldas/32/69160_2.png) [@evaldas](https://community.hubspot.com/u/evaldas)\
**Post date:** [October 17, 2024, 2:26pm UTC](https://community.hubspot.com/t/bulk-api-object-creation-with-associations/118536/2 "2024-10-17T14:26:18Z")

</div>

Hi @Neel-Tandel,

According to the documentation, this might be possible: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/contacts#associations)

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:

```auto
///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!
