APIs & Integrations

gavina
Member

Is it possible to batch read associations (get parent companies)

SOLVE

Hi there,

 

If I have a given set of company ids, is it possible to make a single batch request to find all of their *parent* company ids (or more info about those parents)?

 

The batch company details endpoint doesn't seem to return this information, and so far as I can tell the associations endpoints only allow for checking individiual object associations.

0 Upvotes
1 Accepted solution
dennisedson
Solution
HubSpot Product Team
HubSpot Product Team

Is it possible to batch read associations (get parent companies)

SOLVE

Hey @gavina ,

I did a test with/crm/v3/objects/companies/batch/read endpoint.  This was my payload:

{
  "inputs": [
    {
      "id": "4835913069"
    },
    {"id": "4148303131"}
  ],
  "properties": [
    "hs_parent_company_id"
  ]
}

and this is the response:

{
    "status": "COMPLETE",
    "results": [
        {
            "id": "4835913069",
            "properties": {
                "createdate": "2020-11-16T15:50:03.731Z",
                "hs_lastmodifieddate": "2020-11-16T15:50:16.044Z",
                "hs_object_id": "4835913069",
                "hs_parent_company_id": "4478832048"
            },
            "createdAt": "2020-11-16T15:50:03.731Z",
            "updatedAt": "2020-11-16T15:50:16.044Z",
            "archived": false
        },
        {
            "id": "4148303131",
            "properties": {
                "createdate": "2020-07-10T19:45:18.481Z",
                "hs_lastmodifieddate": "2020-10-22T11:13:37.114Z",
                "hs_object_id": "4148303131",
                "hs_parent_company_id": null
            },
            "createdAt": "2020-07-10T19:45:18.481Z",
            "updatedAt": "2020-10-22T11:13:37.114Z",
            "archived": false
        }
    ],
    "startedAt": "2020-11-16T15:58:30.141Z",
    "completedAt": "2020-11-16T15:58:30.165Z"
}

Unsure if this is what you are looking for, but you can see that you can add multiple company ids into the call and make sure to ask for the hs_parent_company_id to be returned.  Hope this helps!

 

 

View solution in original post

2 Replies 2
dennisedson
Solution
HubSpot Product Team
HubSpot Product Team

Is it possible to batch read associations (get parent companies)

SOLVE

Hey @gavina ,

I did a test with/crm/v3/objects/companies/batch/read endpoint.  This was my payload:

{
  "inputs": [
    {
      "id": "4835913069"
    },
    {"id": "4148303131"}
  ],
  "properties": [
    "hs_parent_company_id"
  ]
}

and this is the response:

{
    "status": "COMPLETE",
    "results": [
        {
            "id": "4835913069",
            "properties": {
                "createdate": "2020-11-16T15:50:03.731Z",
                "hs_lastmodifieddate": "2020-11-16T15:50:16.044Z",
                "hs_object_id": "4835913069",
                "hs_parent_company_id": "4478832048"
            },
            "createdAt": "2020-11-16T15:50:03.731Z",
            "updatedAt": "2020-11-16T15:50:16.044Z",
            "archived": false
        },
        {
            "id": "4148303131",
            "properties": {
                "createdate": "2020-07-10T19:45:18.481Z",
                "hs_lastmodifieddate": "2020-10-22T11:13:37.114Z",
                "hs_object_id": "4148303131",
                "hs_parent_company_id": null
            },
            "createdAt": "2020-07-10T19:45:18.481Z",
            "updatedAt": "2020-10-22T11:13:37.114Z",
            "archived": false
        }
    ],
    "startedAt": "2020-11-16T15:58:30.141Z",
    "completedAt": "2020-11-16T15:58:30.165Z"
}

Unsure if this is what you are looking for, but you can see that you can add multiple company ids into the call and make sure to ask for the hs_parent_company_id to be returned.  Hope this helps!

 

 

gavina
Member

Is it possible to batch read associations (get parent companies)

SOLVE

That's perfect thank you.


I'm basically trying to get a set of data like:

 

{
	'987654321' : {
		hs_contact_id: 987654321
		hs_contact_name: 'gavin'
		associated_company_id: 123456,
		associated_company_name: 'megacorp UK divison',
		associated_company_parent_id: 678910,
		associated_company_parent_name: 'megacorp global',
	},
	...
}

 

From a given set of contact ids.

 

The contact's associated company id's come through in the contact search but after this I'm now doing two batch company searches (for all associated companies, then their parents). So far as I can tell with the above three API calls is the fastest way.