# API returning ghost associations

**URL:** <https://community.hubspot.com/t/api-returning-ghost-associations/49648>\
**Category:** APIs & Integrations\
**Tags:** python, companies, object\
**Created:** [January 12, 2022, 2:20pm UTC](https://community.hubspot.com/t/api-returning-ghost-associations/49648 "2022-01-12T14:20:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RViana](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@RViana](https://community.hubspot.com/u/RViana)\
**Post date:** [January 12, 2022, 2:20pm UTC](https://community.hubspot.com/t/api-returning-ghost-associations/49648/1 "2022-01-12T14:20:21Z")

</div>

I’m having problems with ghost associations, the API it’s returning associations which doesn’t exist.  
In the application, I have only one association, but the API returns old associations which don’t exist anymore.

Request code:

```lia-code-sample
import hubspot
from pprint import pprint
from hubspot.crm.associations import BatchInputPublicObjectId, ApiException

client = hubspot.Client.create(api_key="")

batch_input_public_object_id = BatchInputPublicObjectId(inputs=[{"id":"4471025044"}])
try:
 api_response = client.crm.associations.batch_api.read(from_object_type="deal", to_object_type="company", batch_input_public_object_id=batch_input_public_object_id)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling batch_api->read: %s\n" % e)

```

Response

```lia-code-sample
{
 "status": "COMPLETE",
 "results": [
 {
 "from": {
 "id": "4471025044"
 },
 "to": [
 {
 "id": "422817697",
 "type": "deal_to_company"
 },
 {
 "id": "3152074442",
 "type": "deal_to_company"
 }
 ]
 }
 ],
 "startedAt": "2022-01-12T13:52:37.907Z",
 "completedAt": "2022-01-12T13:52:37.915Z"
}

```

I don’t know if it could have an impact, but those companies have a parent relationship, but also the actively associated companie have parent association with others.  
The API v4 response it’s correct, but since it’s in beta I can’t apply these on our production pipelines.

```lia-code-sample
{
 "results": [
 {
 "toObjectId": 422817697,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 5,
 "label": "Primary"
 }
 ]
 },
 {
 "toObjectId": 3152074442,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 5,
 "label": "Primary"
 }
 ]
 }
 ]

```

---

<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:** [January 13, 2022, 2:12pm UTC](https://community.hubspot.com/t/api-returning-ghost-associations/49648/2 "2022-01-13T14:12:08Z")

</div>

@himanshurauthan ,

have you experienced anything like this?

---

<div class="post-metadata">

**Author:** ![RViana](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@RViana](https://community.hubspot.com/u/RViana)\
**Post date:** [January 13, 2022, 2:27pm UTC](https://community.hubspot.com/t/api-returning-ghost-associations/49648/3 "2022-01-13T14:27:51Z")

</div>

Hey guys, talking with Hubspot support I was able to understand better why this is happening.  
It happened because two deals, associated with two different companies were merged, so when you merge two deals it’s supposed to carry all old associations, but since deals can be associated only with one company, the frontend shows one company, but in the backend, it has two companies associated.  
Now I’m trying to report this bug.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [January 14, 2022, 12:37pm UTC](https://community.hubspot.com/t/api-returning-ghost-associations/49648/4 "2022-01-14T12:37:33Z")

</div>

That’s great you found the solution.
