APIs & Integrations

nigelqwilr
Participant

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Context: 
What we do in Hubspot
We've been leveraging Segment to automatically create contacts in Hubspot. As for companies, we use the automatic association feature to create Hubspot companies. 

What we have in Segment (and our app)

Each user in our app will have a userID and an account ID (groupID in Segement lingo). There can be many accounts under one Company. For example, imagine if we had users from Company ABC. Company ABC will have department X, Y, and Z. Each user will have a user ID but they are mapped to one specific department. Therefore, each department will have a unique account ID.

 

Situation

Following the example from above, our users of Company ABC will be under the the Hubspot company: Company ABC. However, what we want to happen is:

  • For each unique account ID, Hubspot creates a unique Company i.e., Company ABC: Dept X, Company ABC: Dept Y...
  • These companies be associated as a child company to an umbrella Parent Company i.e., Company ABC

 

Questions

  1. Can this be done automatically via Segment (and its Group Call)?
  2. Or maybe a combination of Segment and Hubspot workflows?
  3. Else, what solutions are possible for this scenario?

If anyone has encountered this before/ knows the best resources to do the above, I really appreciate the help!

0 Upvotes
1 Accepted solution
Willson
Solution
HubSpot Employee
HubSpot Employee

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Hi @nigelqwilr 

 

The parent/child relationship for companies is easily managed via the UI but this is a manual process. In terms of automation, you're best working with our APIs.

 

If you're looking for an endpoint to manage parent/child company relationships, you can check out our CRM Associations API 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 > Subscribe to contact.propertyChange and company.propertyChange > When your server received notifications > Use the Associate CRM objects endpoint to create the parent <--> child company relationship. 

 

Once the above is done, you can fetch the IDs of the actual company you want to be added as the associatedCompany and then update the contact record using the Create or update a contact endpoint, like my example below:

Request URL:

https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testContact@hubspot.com/?hapikey={{hapikey}}

Request Body:

      {
      	"property": "associatedcompanyid",
      	"value": "newChildCompanyID"
      }

 

I hope this helps!

Product Manager @ HubSpot

View solution in original post

0 Upvotes
5 Replies 5
Willson
Solution
HubSpot Employee
HubSpot Employee

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Hi @nigelqwilr 

 

The parent/child relationship for companies is easily managed via the UI but this is a manual process. In terms of automation, you're best working with our APIs.

 

If you're looking for an endpoint to manage parent/child company relationships, you can check out our CRM Associations API 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 > Subscribe to contact.propertyChange and company.propertyChange > When your server received notifications > Use the Associate CRM objects endpoint to create the parent <--> child company relationship. 

 

Once the above is done, you can fetch the IDs of the actual company you want to be added as the associatedCompany and then update the contact record using the Create or update a contact endpoint, like my example below:

Request URL:

https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testContact@hubspot.com/?hapikey={{hapikey}}

Request Body:

      {
      	"property": "associatedcompanyid",
      	"value": "newChildCompanyID"
      }

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
nigelqwilr
Participant

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Hey @Willson, thanks that confirms my suspicion for Parent/Child--that we'll have to do that via our own codebase rather than depending on Segment.

 

I wonder if you happen to have an idea for the other questions above as well? To rephrase the questions above, is there a way (ideally through Segment's integration) to create separate Hubspot Companies by referencing to unique Segment Groud Ids rather than a domain?

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Hi @nigelqwilr 

 

Glad to hear I was able to add some clarification in there for you. In relation to your last query, I unfortunately would not be able to shed some light on this - The Segment integration is an external integration and I have no insights into it's current setup. 

 

Without much insight it is hard to make a suggestion here but if an API call can be made via Segment to fetch the data associated to this Group Id, a secondary request could in-turn be made to HubSpot API to create a new record.

 

Unfortunately though, this is not a feature I am aware of with Segment and so would have to be done manually from your end. Perhaps it could be worth mentioning to Segment Support to see if they would have any methods to handle this from their side. 

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
nigelqwilr
Participant

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Thanks for that @Willson . 

 

In that case, one clarification I'd like to check is this then: Segment's documentation says that to create Hubspot Companies, a website URL is used as a unique identifier by Hubspot's Companies API. However, Hubspot's API references for creating a company only has name and description (link).

 

Assuming we can interact with Hubspot's API directly, we won't need a unique URL to create a Hubspot Company? I.e., we can use our own unique account Ids to create Hubspot Companies?

 

Thanks!

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

How to create a Hubspot company (as well as Parent-child relationships) based on Segment group calls

SOLVE

Hi @nigelqwilr 

 

Absolutely not! You will not need a unique URL to create Company Records. The Website URL property is used as a 2nd unique ID internally. 

 

We have automation tools that lookup the domain and provide more data for the company i.e If you create a company HubSpot with the website URL, HubSpot.com, we will see the record created and a few other properties populated as part of our automation. But this is not a mandatory field whatsoever.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes