Is it possible to associate a record with a custom object on POST creation?

Hi, this is basically a follow-up question because you good people on Hubspot are open to ideas from the community.

We are having a situation where we would like to post a custom object and associate this with an existing record.

The post I’m following up from is this:

https://community.hubspot.com/t5/APIs-Integrations/Associate-Contact-Record-with-Custom-Object-on-POST-Create/m-p/713009

This was from November last year, so I am hoping you might have implemented something of this nature in the meanwhile? Otherwise we’d be doubling our requests.

To quote from the post I referenced to:

I see documentation on how to do this with the API as a seperate step- but I wasn’t sure if I could create the Custom Object AND create the association with one API call?

Please advise, since we have a slew of data to synchronise and are aware of rate limits…

Kind regards

Hakun

Need a follow up to this too.
I’m trying to batch create custom objects and associate them to a deal that has already been created.

Hi @HKamminga @SKwon :waving_hand:

Based on HubSpot’s Custom Object API documentation and my own personal testing, this is possible.

Below is an example request where the operation is batch create custom object records while defining associations.

{
 "inputs": [
 {
 "properties": {
 "example_property_1": "Test 1",
 "example_property_2": "Example 1"
 },
 "associations": [
 {
 "to": {
 "id": "123"
 },
 "types": [
 {
 "associationCategory": "USER_DEFINED",
 "associationTypeId": 1
 }
 ]
 },
 {
 "to": {
 "id": "321"
 },
 "types": [
 {
 "associationCategory": "USER_DEFINED",
 "associationTypeId": 2
 }
 ]
 }
 ]
 },
 {
 "properties": {
 "example_property_1": "Test 2",
 "example_property_2": "Example 2"
 },
 "associations": [
 {
 "to": {
 "id": "456"
 },
 "types": [
 {
 "associationCategory": "USER_DEFINED",
 "associationTypeId": 1
 }
 ]
 },
 {
 "to": {
 "id": "654"
 },
 "types": [
 {
 "associationCategory": "USER_DEFINED",
 "associationTypeId": 2
 }
 ]
 }
 ]
 }
 ]
}

In the above request, were are creating 2 custom object records, “Test 1” and “Test 2”. We are also associating these new test records to records (IDs “123”, “321” and “456”, “654”) of 2 other object-types, where the association category is “USER_DEFINED” (association type ID “1” and “2”). To find the associationTypeId(s) relevant to your case, you’ll need to retrieve the relevant custom object schema via API and then go through the “associations” array

(e.g. GET https://api.hubapi.com/crm-object-schemas/v3/schemas/:OBJECT_TYPE)

. More information can be found by navigating to the previously mentioned documentation’s “Object schema” tab, then scrolling down to “Get an existing schema”.

I hope this proves useful. Please let me know if you have any follow-up questions.

Hey @HKamminga,
I’m a little late to the party but have you heard of Associ8? It lets you automatically create associations between objects based on parameters you set. There’s some documentation showing how it works here.
Let me know if you have any questions! I’d be happy to talk with you about it in more detail.
Best,
-David Staat