I am currently working on a project where I am utilizing two custom objects in HubSpot and need to associate them programmatically via the API. The objects are named 'Households' and 'Financial Accounts'. My goal is to associate a financial account to a household once the account is either created or updated. I've tried making a POST request to 'https://api.hubapi.com/crm/v3/objects/associations', but I'm encountering an error message that says 'Unable to infer object type from: associations'.
I believe I may need to use an 'ASSOCIATION_DEFINITION_ID' in my API request, but I'm not sure how to obtain this or if it's the correct approach. Can you please guide me on the right way to make associations between custom objects using the HubSpot API? Also, how do I get the 'ASSOCIATION_DEFINITION_ID' if it is required?
Hey, @Fahadwaseem👋 Welcome to our community! Thanks for the great question 😊
To clarify, you need to both create the association between two Custom Objects and then use those associations between records?
Meaning, you want to:
Create the association definitions between Object_Cats and Object_Dogs? And vice versa? (these associations are unidirectional, meaning you'll need to create and use them for a specific association “direction”) — Object_Cats > Object_Dogs will be different from Object_Dogs > Object_Cats
Create associations for records between these objects? Like associating record Tuexdo Cat with record Yellow Labrador?
Create association types — To create an association type through the API, make a POST request to/crm/v4/associations/{fromObjectType}/{toObjectType}/labels
Associate records — To set up an individual default association between two records, make a PUT request to /crm/v4/objects/{fromObjectType}/{fromObjectId}/associations/default/{toObjectType}/{toObjectId}
You can retrieve the IDs at any time by making a request here
GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels
I hope this helps get you moving forward! — Jaycee
Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.