# API: Find company using ID before merge

**URL:** <https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087>\
**Category:** APIs & Integrations\
**Created:** [December 13, 2022, 10:48am UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087 "2022-12-13T10:48:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PascalB](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PascalB](https://community.hubspot.com/u/PascalB)\
**Post date:** [December 13, 2022, 10:48am UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/1 "2022-12-13T10:48:24Z")

</div>

Hi  
We got some mismatches in our DB that we’d need to update and I assume they mostly come from merges we’ve done on Hubspot.. I’d like to use the API to automate this.  
Is there an API Endpoint that returns the NEW (after merge) company ID by querying using an OLD ID (before merge)?  
Using the browser:  
[https://app.hubspot.com/contacts/XXX/company/ABC](https://app.hubspot.com/contacts/XXX/company/ABC)  
will redirect me to  
[https://app.hubspot.com/contacts/XXX/company/XYZ](https://app.hubspot.com/contacts/XXX/company/ABC)  
I’d need to find this mapping (ABC =\> XYZ) using the API.  
Any hints?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [December 13, 2022, 5:57pm UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/2 "2022-12-13T17:57:02Z")

</div>

Hey, @PascalB 👋 Thanks for reaching out. I misread your initial question and found a solution for finding the old ID by using the new ID 🙃 I’ll leave it in case it helps others in the future. But it did give me something to test with. I didn’t see it in the documentation, but it works.

Can you try this?

- Take one of your “old” IDs

- Use the endpoint here — [Get a Company by ID](https://developers.hubspot.com/docs/api/crm/companies)

- Use the query param — “hs\_merged\_object\_ids”

- Use one of the old IDs in your request for “companyId”

Here’s what I did:

- I took my “old” ID “10343620270” and made this request

- And it returned the object as the “new” ID

- The ID is the “new” company that the “old” ID was merged into

 ![hsmid-02.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/8/183af02aee6061bfa1946237d51aed668b5bf186.jpeg)

To find merged IDs from current ID

I tried the solution from this thread (shoutout to [@klloyd\_\_1](https://community.hubspot.com/t5/user/viewprofilepage/user-id/381293) for the solution 🙌) and was successful.

My quick test:

- Create Companies A, B, C

- Merge (in-app) A and B \> C

- Use the endpoint here — [Get a Company by ID](https://developers.hubspot.com/docs/api/crm/companies)

- Use the query param — “hs\_merged\_object\_ids”

- My request

- The response + screenshot to show merged IDs

 ![hsmid-01.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/6/46b67dea84bd6baaddd5b7dc08fbeeb18cbfb28c.jpeg)

Have fun building! — Jaycee

---

<div class="post-metadata">

**Author:** ![PascalB](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PascalB](https://community.hubspot.com/u/PascalB)\
**Post date:** [December 13, 2022, 9:02pm UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/3 "2022-12-13T21:02:42Z")

</div>

Hi Jaycee  
This looks very promising. I will test it tomorrow.  
Thanks.  
Pascal

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [December 13, 2022, 9:05pm UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/4 "2022-12-13T21:05:32Z")

</div>

Awesome! Please let us know how it works. — Jaycee

---

<div class="post-metadata">

**Author:** ![PascalB](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PascalB](https://community.hubspot.com/u/PascalB)\
**Post date:** [December 14, 2022, 9:49am UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/5 "2022-12-14T09:49:58Z")

</div>

Works like a charm.  
➜ curl --request GET \  
--url ‘[https://api.hubapi.com/crm/v3/objects/companies/ABC?properties=hs\_merged\_object\_ids&archived=false](https://api.hubapi.com/crm/v3/objects/companies/ABC?properties=hs_merged_object_ids&archived=false)’ \  
--header ‘authorization: Bearer XXX’ | jq ‘.id’  
“XYZ”

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [December 14, 2022, 3:35pm UTC](https://community.hubspot.com/t/api-find-company-using-id-before-merge/71087/6 "2022-12-14T15:35:49Z")

</div>

Hi, @PascalB 👋 Thanks for letting us know! — Jaycee
