# Guidance Needed: Associating Two Custom Objects via HubSpot API using Python

**URL:** <https://community.hubspot.com/t/guidance-needed-associating-two-custom-objects-via-hubspot-api-using-python/85351>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [July 14, 2023, 9:06am UTC](https://community.hubspot.com/t/guidance-needed-associating-two-custom-objects-via-hubspot-api-using-python/85351 "2023-07-14T09:06:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fahadwaseem](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fahadwaseem](https://community.hubspot.com/u/Fahadwaseem)\
**Post date:** [July 14, 2023, 9:06am UTC](https://community.hubspot.com/t/guidance-needed-associating-two-custom-objects-via-hubspot-api-using-python/85351/1 "2023-07-14T09:06:50Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [July 14, 2023, 10:11pm UTC](https://community.hubspot.com/t/guidance-needed-associating-two-custom-objects-via-hubspot-api-using-python/85351/2 "2023-07-14T22:11:18Z")

</div>

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?

You can do both from the [**Associations v4 page**](https://developers.hubspot.com/docs/api/crm/associations):

- [Create association types](https://developers.hubspot.com/docs/api/crm/associations#:~:text=Create%20association%20types) — To create an association type through the API, make a `POST` request to `/crm/v4/associations/{fromObjectType}/{toObjectType}/labels`
- [Associate records](https://developers.hubspot.com/docs/api/crm/associations#:~:text=unlabeled%20association%20type.-,Associate%20records,-You%20can%20create) — 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](https://developers.hubspot.com/docs/api/crm/associations#:~:text=Retrieve%20association%20types)

`GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels`

I hope this helps get you moving forward! — Jaycee
