APIs & Integrations

DBellavance
Member

Get all associated company of a contact

SOLVE

Hi,

 

We have contacts with multiple company associated with them. One of the company is the primary and I'm able to get the primary company id of the by checking the "associated-company".

 

But I cannot find the a way to query the secondary company through the API.

 

I've tried also querying using the Associations API.

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Get all associated company of a contact

SOLVE

Hey, @DBellavance 👋 Can you share an example request and response? I tried from the associations endpoint and returned both the primary and additional associated companies for my contact, Bob Belcher. 

Quick example:

  • Contact 
    CleanShot 2023-02-03 at 17.37.14.png
  • Request
    curl --request GET \
      --url 'https://api.hubapi.com/crm/v4/objects/0-1/901/associations/0-2?limit=500' \
      --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
  • Response 
    HTTP 200
    
    {
      "results": [
        {
          "toObjectId": 10202231613,
          "associationTypes": [
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 1,
              "label": "Primary"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        },
        {
          "toObjectId": 11685858563,
          "associationTypes": [
            {
              "category": "USER_DEFINED",
              "typeId": 27,
              "label": "Test 1"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        },
        {
          "toObjectId": 11685858582,
          "associationTypes": [
            {
              "category": "USER_DEFINED",
              "typeId": 31,
              "label": "Vendor"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        }
      ]
    }​

Thanks! — Jaycee

 

 

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Get all associated company of a contact

SOLVE

Hey, @DBellavance 👋 Can you share an example request and response? I tried from the associations endpoint and returned both the primary and additional associated companies for my contact, Bob Belcher. 

Quick example:

  • Contact 
    CleanShot 2023-02-03 at 17.37.14.png
  • Request
    curl --request GET \
      --url 'https://api.hubapi.com/crm/v4/objects/0-1/901/associations/0-2?limit=500' \
      --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
  • Response 
    HTTP 200
    
    {
      "results": [
        {
          "toObjectId": 10202231613,
          "associationTypes": [
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 1,
              "label": "Primary"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        },
        {
          "toObjectId": 11685858563,
          "associationTypes": [
            {
              "category": "USER_DEFINED",
              "typeId": 27,
              "label": "Test 1"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        },
        {
          "toObjectId": 11685858582,
          "associationTypes": [
            {
              "category": "USER_DEFINED",
              "typeId": 31,
              "label": "Vendor"
            },
            {
              "category": "HUBSPOT_DEFINED",
              "typeId": 279,
              "label": null
            }
          ]
        }
      ]
    }​

Thanks! — Jaycee

 

 

 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

GBersac8
Participant

Get all associated company of a contact

SOLVE

How do we find the toObjectId value?

0 Upvotes