Find obsolete associations

Hi
I am fairly new to HubSpot, but I am already beginning to get a good understanding of Objects and Custom Objects, reading, creating, deleting, merge and updating records.
One thing I am struggling with is associations.

I am in the process of cleaning out some old code, that unfortunately create multiple copies of the same company. What I am missing now, is the cleaning of the associations and relationships between objects.
What I can read from the documentation, then a relationship between objects is not deleted if one of the objects is deleted.

That would mean, that I have a bunch of orphaned objects now.

Like I can get a list of all my Companies, and all entries in my custom object Employees, I simply can’t figure out, how to get all the relations between these two objects.

It seems to me, in order to get that I would have to ask for each Company ID (batch) but that would only give me the active relations.

How can I get all the relation objects ids in an association, so I can verify the ones that are still valid, and change/delete the ones that that are wrong?

Br ()

Thomas

Hi @Verakso

I hope the attached curl will resolve your query-

curl --request GET \
 --url 'https://api.hubapi.com/crm/v3/objects/companies?limit=10&associations=employees&archived=false' \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

I am also attaching a HubSpot Knowledge base link for more reference and clarity.

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.

Thanks!

That seems to be exactly what I was loooking for.

I might be doing things a litle bit backwards, but I like to extract the data, and then do some validation my self, and this snippet certainly helped.
Thanks!