Getting the association label of the association between two specific objects

Hi!

Is there any way to get the association label / id of the association between two specific objects in an API request? I have set a custom association label for contacts and deals and am now trying to access the contacts associated to a given deal with that specific label. Sadly, I can only find documentation on retrieving all association types in general and associating records with a custom association type.

Thanks in advance!

Hey, @hsusernk :waving_hand: Welcome to the community.

Have you tried the request here? — Retrieve association types.

Here’s my quick example (and please let me know if you are trying to get at something different :blush:)

  • Created a custom label for Contacts > Deals — Cat Magician

  • Used this request
    GET /crm/v4/associations/contacts/deals/labels​

  • Response

    {
     "results": [
     {
     "category": "HUBSPOT_DEFINED",
     "typeId": 4,
     "label": null
     },
     {
     "category": "USER_DEFINED",
     "typeId": 25,
     "label": "Cat Magician"
     }
     ]
    }​
    

Have fun building!

Jaycee

Thank you very much for your help! While this help me get the combinations of typeIds and labels, it still doesn’t solve my problem of finding out which deal-contact association has which association type. Is there any way to approach this or am I missing something?

I am seeking this very solution. Did you ever find a way to do it? I want to “get associations” of only one particular association label.

I believe you can do this just using the CRM object API of your choice. For example, if I want to read the association labels of all contacts associated with a deal, I could make a call like https://api.hubapi.com/crm/v3/objects/deals/14125553408?properties=dealstage&archived=false&associations=contacts

And it will give me a list of all associated contacts along with their labels if they have them:

{
 "id": "14125553408",
 "properties": {
 "createdate": "2023-07-13T18:45:32.184Z",
 "dealstage": "60670224",
 "hs_lastmodifieddate": "2023-07-14T12:00:50.941Z",
 "hs_object_id": "14125553408"
 },
 "createdAt": "2023-07-13T18:45:32.184Z",
 "updatedAt": "2023-07-14T12:00:50.941Z",
 "archived": false,
 "associations": {
 "contacts": {
 "results": [
 {
 "id": "5976801",
 "type": "deal_to_contact"
 },
 {
 "id": "14418951",
 "type": "deal_to_contact"
 },
 {
 "id": "14419401",
 "type": "deal_to_contact"
 },
 {
 "id": "15959851",
 "type": "deal_to_contact"
 },
 {
 "id": "14418951",
 "type": "business-payments"
 },
 {
 "id": "5976801",
 "type": "c-level_executive_sponsor"
 },
 {
 "id": "5976801",
 "type": "primary_contact"
 }
 ]
 }
 }
}

Just keep in mind that contacts with multiple association labels will show up once for each association label they have, such as the contact above that is marked as both an executive sponsor and a primary contact.