# Multiple associations through API

**URL:** <https://community.hubspot.com/t/multiple-associations-through-api/44844>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [October 5, 2021, 1:56pm UTC](https://community.hubspot.com/t/multiple-associations-through-api/44844 "2021-10-05T13:56:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HBrandao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hbrandao/32/104913_2.png) [@HBrandao](https://community.hubspot.com/u/HBrandao)\
**Post date:** [October 5, 2021, 1:56pm UTC](https://community.hubspot.com/t/multiple-associations-through-api/44844/1 "2021-10-05T13:56:15Z")

</div>

I am currently on the beta for the flexible associations and I am struggling on how can I associate multiple companies to the same contact through the API.

As of now, I can perform the associations with no issues on the UI. However, when I try to replicate the same issue through the API, I am reaching a dead-end.

```lia-code-sample
import hubspot
from hubspot.crm.associations import BatchInputPublicAssociation, ApiException
client = hubspot.Client.create(api_key='api_key')

payload = [{
"from":{"id":"592476"},
"to":[
{"id":"4840447981","type":"contact_to_company"},
{"id":"4840447986","type":"contact_to_company_unlabeled"},
{"id":"4840448191","type":"contact_to_company_unlabeled"},
{"id":"4840448194","type":"contact_to_company_unlabeled"},
{"id":"4840448206","type":"contact_to_company_unlabeled"},
{"id":"4840448220","type":"contact_to_company_unlabeled"},
{"id":"4840448442","type":"contact_to_company_unlabeled"}]}]

batch_input_public_association = BatchInputPublicAssociation(inputs=payload)
try:
api_response = client.crm.associations.batch_api.create(from_object_type="contact", to_object_type="company", batch_input_public_association=batch_input_public_association)
print(api_response)
except ApiException as e:
print("Exception when calling batch_api->create: %s\n" % e)

```

I am currently getting this error:

`message":"Invalid input JSON on line 1, column 46: Cannot deserialize instance of `com.hubspot.apiutils.core.models.PublicObjectId$Json` out of START_ARRAY token","correlationId":"fbc3fe63-c3be-4f94-8bda-8826111b421f`

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 5, 2021, 5:59pm UTC](https://community.hubspot.com/t/multiple-associations-through-api/44844/2 "2021-10-05T17:59:00Z")

</div>

@HBrandao

Have you had a chance to check out the [docs](https://developers.hubspot.com/docs/api/crm/associations/v4) for the new endpoints? Was just made available.

---

<div class="post-metadata">

**Author:** ![GrantCarlile](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grantcarlile/32/227388_2.png) [@GrantCarlile](https://community.hubspot.com/u/GrantCarlile)\
**Post date:** [December 9, 2021, 11:17pm UTC](https://community.hubspot.com/t/multiple-associations-through-api/44844/3 "2021-12-09T23:17:10Z")

</div>

How’s it going? What’s the status?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [December 10, 2021, 1:33am UTC](https://community.hubspot.com/t/multiple-associations-through-api/44844/4 "2021-12-10T01:33:49Z")

</div>

Hey @GrantCarlile !

Was that directed at me or @HBrandao ?
