# Getting Associations in Batch APIs

**URL:** <https://community.hubspot.com/t/getting-associations-in-batch-apis/52704>\
**Category:** APIs & Integrations\
**Created:** [March 8, 2022, 6:30am UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704 "2022-03-08T06:30:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SR36](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SR36](https://community.hubspot.com/u/SR36)\
**Post date:** [March 8, 2022, 6:30am UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/1 "2022-03-08T06:30:30Z")

</div>

Is there a way to retrieve associations in a Batch Read. For example, when retrieving a single contact, I can request for associations via the GET API as follows

curl --request GET --url [[https://api.hubapi.com/crm/v3/objects/contacts/251/\\](https://api.hubapi.com/crm/v3/objects/contacts/251/%5C%5C)]([https://api.hubapi.com/crm/v3/objects/contacts/251/\](https://api.hubapi.com/crm/v3/objects/contacts/251/%5C))?associations\=notes --header ‘authorization: Bearer \<token\>’ | json\_pp

% Total % Received % Xferd Average Speed Time Time Time Current

```
                             Dload Upload Total Spent Left Speed

```

100 432 0 432 0 0 352 0 --:--:-- 0:00:01 --:--:-- 357

{

“archived” : false,

“associations” : {

```
  "notes" : {

     "results" : \[

        {

           "id" : "19668463257",

           "type" : "contact\_to\_note"

        },

        {

           "id" : "19793682071",

           "type" : "contact\_to\_note"

        }

     ]

  }

```

},

“createdAt” : “2022-03-03T09:23:21.321Z”,

“id” : “251”,

“properties” : {

```
  "createdate" : "2022-03-03T09:23:21.321Z",

  "email" : "bcooper@biglytics.net",

  "firstname" : "Bryan",

  "hs\_object\_id" : "251",

  "lastmodifieddate" : "2022-03-04T03:08:28.978Z",

  "lastname" : "Cooper"

```

},

“updatedAt” : “2022-03-04T03:08:28.978Z”

}

But when trying to use batch operations is there a way to retrieve associations in the response. I tried the following but did not work. From API there seems to be no way to achieve this. Is there any other way to do this?

curl --request POST \

--url [https://api.hubapi.com/crm/v3/objects/contacts/batch/read](https://api.hubapi.com/crm/v3/objects/contacts/batch/read) \

--header ‘authorization: Bearer \<token\>’ \

--header ‘content-type: application/json’ \

--data '{

“inputs”: [

```
{

  "id": "251"

}

```

],

“associations”: [

```
"notes"

```

]

}’ | json\_pp

% Total % Received % Xferd Average Speed Time Time Time Current

```
                             Dload Upload Total Spent Left Speed

```

100 501 0 415 100 86 335 69 0:00:01 0:00:01 --:--:-- 408

{

“completedAt” : “2022-03-08T06:27:11.024Z”,

“results” : [

```
  {

     "archived" : false,

     "createdAt" : "2022-03-03T09:23:21.321Z",

     "id" : "251",

     "properties" : {

        "createdate" : "2022-03-03T09:23:21.321Z",

        "email" : "bcooper@biglytics.net",

        "firstname" : "Bryan",

        "hs\_object\_id" : "251",

        "lastmodifieddate" : "2022-03-04T03:08:28.978Z",

        "lastname" : "Cooper"

     },

     "updatedAt" : "2022-03-04T03:08:28.978Z"

  }

```

],

“startedAt” : “2022-03-08T06:27:10.999Z”,

“status” : “COMPLETE”

}

---

<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:** [March 9, 2022, 4:27pm UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/2 "2022-03-09T16:27:17Z")

</div>

@SR36

Have you explored the [CRM search api](https://developers.hubspot.com/docs/api/crm/search)? You can return associations with that

---

<div class="post-metadata">

**Author:** ![SR36](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SR36](https://community.hubspot.com/u/SR36)\
**Post date:** [May 25, 2022, 8:48am UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/3 "2022-05-25T08:48:08Z")

</div>

Thanks. I ended up using the search API, but this was sub optimal as I already had the list of contacts with ids

---

<div class="post-metadata">

**Author:** ![sfroment](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sfroment](https://community.hubspot.com/u/sfroment)\
**Post date:** [August 25, 2022, 8:09am UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/4 "2022-08-25T08:09:07Z")

</div>

Hey,

@SR36 @dennisedson  
How did you return the associations using the search api ?  
It seems like many aren’t knowing how to do this also [https://community.hubspot.com/t5/APIs-Integrations/Get-associations-with-deals-from-crm-objects-deals-search/m-p/321104](https://community.hubspot.com/t5/APIs-Integrations/Get-associations-with-deals-from-crm-objects-deals-search/m-p/321104)  
Thanks !

---

<div class="post-metadata">

**Author:** ![SR36](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@SR36](https://community.hubspot.com/u/SR36)\
**Post date:** [October 6, 2022, 12:21pm UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/5 "2022-10-06T12:21:00Z")

</div>

Hi @sfroment ,

I dont think we can get associations via the search API. As a result I had to do this in a sub optimal convoluted way 😞

1) Execute a search query

2) For all returned records, call the batch association API to get the list of associations

3) The returned association is in turn sparse, it does not have the name of the contact, company or deal. So make further batch requests to get these information

This is definitely not ideal. I’m not sure why assocaitions is not exposed in search while its exposed in list API

---

<div class="post-metadata">

**Author:** ![sfroment](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sfroment](https://community.hubspot.com/u/sfroment)\
**Post date:** [October 6, 2022, 12:25pm UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/6 "2022-10-06T12:25:24Z")

</div>

Yes indeed it is the solution I also implemented 😞

---

<div class="post-metadata">

**Author:** ![elephantal](https://avatars.discourse-cdn.com/v4/letter/e/edb3f5/32.png) [@elephantal](https://community.hubspot.com/u/elephantal)\
**Post date:** [November 21, 2024, 4:31pm UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/7 "2024-11-21T16:31:08Z")

</div>

How did you get batch associations from the API? I can’t seem to find that functionality. Can only fetch associations one at a time.

---

<div class="post-metadata">

**Author:** ![CMarl](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@CMarl](https://community.hubspot.com/u/CMarl)\
**Post date:** [October 19, 2022, 4:00pm UTC](https://community.hubspot.com/t/getting-associations-in-batch-apis/52704/8 "2022-10-19T16:00:31Z")

</div>

@dennisedson it appears we _cannot_ get associations through the search api either. please advise..
