Node API: Create Custom Objects with Associations is not saving Associations

I’m working on a script to import my company’s data into Hubspot using the Hubspot Node package.

I’ve encountered the issue of not being able to make custom same-type associations, so my solution is to make a custom object to “bridge the gap” between records of the same type. To keep things neatly organized I’m using this object to associate different-type records in the same association category as well.

The issue I’m having is:
When creating a new record, I’m passing the object required to generate the record, including properties AND associations, but only the properties are being created - associations are lost.

I’ve taken this bit of code out of my application and tested it in a vacuum, with hard-coded values exactly how the docs describe, and still am having no luck.


Test


Results

Is there currently a bug in the crm.objects part of the API? Any idea how to solve?

Thanks,

Skylar

Hey, @SMacias :waving_hand: Thanks for your question.

Can you add your example using the code block tool, please? It’s hard for the community to troubleshoot our code from a screenshot.

Thank you! — Jaycee

Sure, here it is:

const hubspot = require('@hubspot/api-client')playground()async function playground(){ const config = { accessToken: 'xxx-xxx-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', numberOfApiCallRetries: 3 } var hubspotClient = new hubspot.Client(config); var objectType = "investments" var SimplePublicObjectInputForCreate = { properties: { name: 'Test Investment', entity_type: 'Company' }, associations: [ { "to": {"id": "15766174075"}, "types":[{"associationCategory":"USER_DEFINED","associationTypeId": 157}] }, { "to": {"id": "15609171770"}, "types":[{"associationCategory":"USER_DEFINED","associationTypeId": 159}] } ] } var res = await hubspotClient.crm.objects.basicApi.create(objectType, SimplePublicObjectInputForCreate); console.log(res);}

Has this issue been resolved?

Hi @OM19 and welcome back, so nice to see you again! :orange_heart:

Thanks for checking with the HubSpot Community!

Usually, the most common cause of associations being silently dropped is an incorrect associationTypeId.

I’d suggest checking the following please:

  • associationTypeId must be correct for your custom object. For custom objects, these IDs are not the standard HubSpot-defined ones, you need to retrieve them via a GET to /crm/associations/2026-03/{fromObjectType}/{toObjectType}/labels/. Using a wrong ID won’t throw an error; associations are just silently ignored.

  • associationCategory must match the type. Use USER_DEFINED for custom association labels, HUBSPOT_DEFINED for default ones.

  • The association type must be pre-defined between the two object types via the schemas API before you can use it in a create request.

Here are some resources for more details:

I’d love to hear the insights from our Top Experts: Hi @Anton and @evaldas do you have suggestions to help @OM19, please?

Thanks so much and wishing you a brilliant day!
Bérangère

This post was created with the assistance of AI tools

This issue was raised 3 years ago, and there’s no definitive answer? If it’s a payload issue, then the API should not return an OK status, that’s misleading. I will try creating the associations separately now, but I also see there are people saying that doesn’t work either, that you have to create the association one by one.

Hi @OM19 and thanks for your valuable feedback, I’ve passed it along internally.

Creating associations separately via POST /crm/v3/associations/{fromObjectType}/{toObjectType}/batch/create is a great alternative, it supports batching up to multiple associations per request, not just one at a time.

But please let us know if you run into any challenges while using this endpoint, feel free to share more details here (like the method used, the body and the response, without any confidential nor sensitive data), and we’ll work with you to find the best path forward.

We appreciate you bringing this up, thank you.

Bérangère