APIs & Integrations

hsusernk
Member

Getting the association label of the association between two specific objects

SOLVE

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!

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Getting the association label of the association between two specific objects

SOLVE

Hey, @hsusernk 👋 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 😊)

  • Created a custom label for Contacts > Deals — Cat Magician
    cm-1.png
  • 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

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
4 Replies 4
Jaycee_Lewis
Solution
Community Manager
Community Manager

Getting the association label of the association between two specific objects

SOLVE

Hey, @hsusernk 👋 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 😊)

  • Created a custom label for Contacts > Deals — Cat Magician
    cm-1.png
  • 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

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
hsusernk
Member

Getting the association label of the association between two specific objects

SOLVE

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?

Hollyce
Contributor | Diamond Partner
Contributor | Diamond Partner

Getting the association label of the association between two specific objects

SOLVE

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. 

 

0 Upvotes
brennan-nowers
Member

Getting the association label of the association between two specific objects

SOLVE

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&associat...

 

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.

0 Upvotes