Update custom object properties and associations in one request

Hi,

When creating a custom object, I can send a single POST request to push both the associations and the properties of the new object.

I send a POST request to:

https://api.hubapi.com/crm/v3/objects/{objectType}

with the following structure:

data = {
'associations': 
[{'to': {'id': TO_OBJECT_ID}, 
'types': [{
'associationCategory': 'USER_DEFINED', 
'associationTypeId': ASSOCIATION_TYPE_ID
}]}], 
'properties': {...}
}

The object is created successfully with the correct properties and associations.

When trying to update the object (both properties and associations), I use a similar POST request to the endpoint:

https://api.hubapi.com/crm/v3/objects/{objectType}/{objectId}

with the same data structure:

data = {
'associations': 
[{'to': {'id': TO_OBJECT_ID}, 
'types': [{
'associationCategory': 'USER_DEFINED', 
'associationTypeId': ASSOCIATION_TYPE_ID
}]}], 
'properties': {...}
}

However, even though I receive a Response [200], only the properties are updated.

Do you know if updating properties and associations within the same request is supported?

The associations between objects change over time, and I would like to update them within a single API request.

Thank you.

Hi @FelipeV

HubSpot’s API has a limitation that prevents updating both properties and associations simultaneously through a single POST request to the update endpoint.

Though you received a 200 response indicating successful property updates, the associations were not updated.

To achieve your desired outcome, you can employ one of two approaches: either make separate requests, where you first use a PATCH request to update properties through the update endpoint, and then make a separate POST request to the associations endpoint to update associations; or use a batch request, which allows you to bundle multiple requests into a single API call, enabling you to update both properties and associations in a single request.

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Thanks @Humashankar would be good if Hubspot enables this feature. Will make everything more efficient.

Hi @FelipeV

I completely agree!

Having this feature in HubSpot would streamline our workflow and save us so much time.

I encourage you to submit this suggestion in the ideas section, and the product team to take it forward !!

Regards