# Automating parent child relationship

**URL:** <https://community.hubspot.com/t/automating-parent-child-relationship/18235>\
**Category:** APIs & Integrations\
**Tags:** companies, workflows, events, contacts\
**Created:** [January 21, 2020, 10:03am UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235 "2020-01-21T10:03:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![somdutt](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/somdutt/32/38459_2.png) [@somdutt](https://community.hubspot.com/u/somdutt)\
**Post date:** [January 21, 2020, 10:03am UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/1 "2020-01-21T10:03:52Z")

</div>

Is there any functionality where we can trigger flow to assign parent/child company to an company automatically based upon a property change of company/contact ?

---

<div class="post-metadata">

**Author:** ![Willson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/willson/32/84663_2.png) [@Willson](https://community.hubspot.com/u/Willson)\
**Post date:** [January 21, 2020, 2:34pm UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/2 "2020-01-21T14:34:05Z")

</div>

Hi @somdutt

There isn’t currently an endpoint to automate the process of assigning Parent/Child companies. This is still currently a manual process that must be done via the User Interface.

I’m not aware of plans to implement such an API, but I’d be happy to pass this idea along internally.

I’d also recommend posting this to the Ideas Forum on the [HubSpot Community](https://community.hubspot.com/).

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [January 22, 2020, 2:45am UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/3 "2020-01-22T02:45:11Z")

</div>

Hey @somdutt,

If you’re looking for an endpoint to manage parent \<--\> child company relationship using HubSpot API, you can check out this documentation - [CRM Associations API Overview](https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview).

The CRM Associations API is being updated to support two new association types:

- Parent company to child company, definition ID = 13  
- Child company to parent company,definition ID = 14

For your use case, I’d recommend for you to use HubSpot’s [Webhooks API](https://developers.hubspot.com/docs/methods/webhooks/webhooks-overview) \> Subscribe to contact.propertyChange and company.propertyChange \> When your server received notifications \> Use the [Associate CRM objects endpoint](https://developers.hubspot.com/docs/methods/crm-associations/associate-objects) to create the parent \<--\> child company relationship.

---

<div class="post-metadata">

**Author:** ![MatthewBoyd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matthewboyd/32/52911_2.png) [@MatthewBoyd](https://community.hubspot.com/u/MatthewBoyd)\
**Post date:** [July 17, 2020, 1:38am UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/4 "2020-07-17T01:38:00Z")

</div>

Hi there,

If this is still something you are looking for, [@Dave\_](https://community.hubspot.com/t5/user/viewprofilepage/user-id/108314) at [Integration Fox](https://www.integrationfox.com/contact/) has built a tool for us that does this really well and is able to recreate it for others incredibly affordably.

Based on setting a Parent Company ID property either manually or via an import, Integration Fox automatically creates a Parent/Child relationship with the matching Company.

Easy!

---

<div class="post-metadata">

**Author:** ![Fatedx](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@Fatedx](https://community.hubspot.com/u/Fatedx)\
**Post date:** [March 23, 2022, 11:22pm UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/5 "2022-03-23T23:22:18Z")

</div>

The HubSpot API v3 was released into general availability on March 31st, 2020 (just 2 months after the solution was posted here). For anyone using v3 of the API:  
You can get a list of valid associations for company-to-company objects in Node like this:

```lia-code-sample
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'YOUR_HUBSPOT_API_KEY ' });

hubspotClient.crm.associations.typesApi
 .getAll('companies', 'companies')
 .then(({ body }) => {
 console.log(JSON.stringify(data.body, null, 2));
 });

```

The response lets us know that the following 2 associationTypes exist: **parent\_to\_child\_company** and **child\_to\_parent\_company**. With this, we can create a child-to-parent association like so:

```lia-code-sample
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'YOUR_HUBSPOT_API_KEY ' });

const childCompanyId = 'YOUR_HUBSPOT_CHILD_COMPANY_ID';
const parentCompanyId = 'YOUR_HUBSPOT_PARENT_COMPANY_ID';
hubspotClient.crm.companies.associationsApi.create(
 childCompanyId,
 'companies',
 parentCompanyId,
 'child_to_parent_company',
);

```

And for a parent-to-child association, simply switch the order of Id parameters and change the last parameter to ‘_parent\_to\_child\_company_’.

---

<div class="post-metadata">

**Author:** ![RBozeman](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rbozeman/32/8786_2.png) [@RBozeman](https://community.hubspot.com/u/RBozeman)\
**Post date:** [October 24, 2022, 11:13pm UTC](https://community.hubspot.com/t/automating-parent-child-relationship/18235/6 "2022-10-24T23:13:09Z")

</div>

Hi @somdutt,

As far as I know you either have to use the API or potentially custom code something for this in Operations Hub.

It’s important to keep in mind that you’ll need some way to identify parent companies within the data itself. For example, a common way of doing this is to append “HQ” onto the parent company’s name. So, “HubSpot HQ,” for example. And the child companies are associated to that parent company.

Also wanted to mention that [Insycle](https://app.hubspot.com/ecosystem/6303986/marketplace/apps/marketing/data-management/insycle) can do this. For full disclosure, I work there as a product marketer. But Insycle allows you to automate associations (even in workflows) between child and parent companies, using any field in your database as a matching field. It can also manage multiple associations and association labels in bulk as well.

Best,

Ryan
