# Create a Custom Object with associations

**URL:** <https://community.hubspot.com/t/create-a-custom-object-with-associations/120718>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [November 18, 2024, 12:39pm UTC](https://community.hubspot.com/t/create-a-custom-object-with-associations/120718 "2024-11-18T12:39:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flpeSouza](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@flpeSouza](https://community.hubspot.com/u/flpeSouza)\
**Post date:** [November 18, 2024, 12:39pm UTC](https://community.hubspot.com/t/create-a-custom-object-with-associations/120718/1 "2024-11-18T12:39:41Z")

</div>

I’m trying to create an item in an object that is already associated with a contact…

My endpoint: [https://api.hubapi.com/crm/v3/objects/financeiro](https://api.hubapi.com/crm/v3/objects/financeiro)

My body:  
{  
“properties”: {  
“nome”: “Fatura - 27625 - CTE24371/37913”,  
“hs\_pipeline”: “147734376”,  
“hs\_pipeline”: “636407452”,  
“cnpj”: “29951608000183”,  
“codigo\_pn”: “4092650”,  
“valor\_da\_fatura”: “295.25”,  
“valor\_pago”: “0”,  
},  
“associations”: [  
{  
“to”: {  
“id”: 76665984395  
},  
“types”: [  
{  
“associationCategory”: “HUBSPOT\_DEFINED”,  
“associationTypeId”: 16  
}  
]  
}  
]  
}

However, the HubSpot API returns an error:

invalid from object type 2-36186255 for associations to be created. expected: 0-5

I can’t identify what the error is and how to fix it. Can you help me?

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [November 18, 2024, 4:52pm UTC](https://community.hubspot.com/t/create-a-custom-object-with-associations/120718/2 "2024-11-18T16:52:46Z")

</div>

Hi @flpeSouza and welcome to the Community, it’s a pleasure to have you here!

Thanks for asking us!

I have found this similar post “[Custom Objects & Associations API v4](https://community.hubspot.com/t5/APIs-Integrations/Custom-Objects-amp-Associations-API-v4/m-p/627365)” where the solution from @LMeert might help you!  
Also, I’d love to put you in touch with some of our Top Experts:

Hi @Bortami, @HubSpot_Corey and @ChrisoKlepke do you have suggestions to help @flpeSouza, please?

Thanks so much and have a great day!

Best,  
Bérangère

---

<div class="post-metadata">

**Author:** ![Bortami](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bortami/32/221350_2.png) [@Bortami](https://community.hubspot.com/u/Bortami)\
**Post date:** [November 18, 2024, 5:16pm UTC](https://community.hubspot.com/t/create-a-custom-object-with-associations/120718/3 "2024-11-18T17:16:44Z")

</div>

The error is telling you that you need to include the correct associationTypeId and associationCategory.

associationCategory: HUBSPOT\_DEFINED and associationTypeID: 16 is the Ticket to Contact associations. ([list of HubSpot Defined associations here](https://developers.hubspot.com/beta-docs/guides/api/crm/associations/associations-v4#association-type-id-values))

To get the correct association category and type id, you can view the API details in the UI (Settings \> Objects \> Associations) or by calling /crm/v4/objects/{objectType}/{objectId}/associations/{toObjectType}
