API: Find company using ID before merge

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
will redirect me to
https://app.hubspot.com/contacts/XXX/company/XYZ
I’d need to find this mapping (ABC => XYZ) using the API.
Any hints?

Hey, @PascalB :waving_hand: Thanks for reaching out. I misread your initial question and found a solution for finding the old ID by using the new ID :upside_down_face: 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

    GET
    /crm/v3/objects/companies/{companyId}​
    
  • 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

    curl --request GET \
     --url 'https://api.hubapi.com/crm/v3/objects/companies/10343620270?properties=hs_merged_object_ids&archived=false' \
     --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    
  • And it returned the object as the “new” ID

    HTTP 200
    
    {
     "id": "10343610802",
     "properties": {
     "createdate": "2022-12-13T17:30:34.708Z",
     "hs_lastmodifieddate": "2022-12-13T17:33:58.486Z",
     "hs_merged_object_ids": "10343620270;10343620448",
     "hs_object_id": "10343610802"
     },
     "createdAt": "2022-12-13T17:30:34.708Z",
     "updatedAt": "2022-12-13T17:33:58.486Z",
     "archived": false
    }
    
  • The ID is the “new” company that the “old” ID was merged into

To find merged IDs from current ID

I tried the solution from this thread (shoutout to @klloyd__1 for the solution :raising_hands:) 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

    GET
    /crm/v3/objects/companies/{companyId}​
    
  • Use the query param — “hs_merged_object_ids”

  • My request

    curl --request GET \
     --url 'https://api.hubapi.com/crm/v3/objects/companies/10343610802?properties=hs_merged_object_ids&archived=false' \
     --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    
  • The response + screenshot to show merged IDs

    HTTP 200
    
    {
     "id": "10343610802",
     "properties": {
     "createdate": "2022-12-13T17:30:34.708Z",
     "hs_lastmodifieddate": "2022-12-13T17:33:58.486Z",
     "hs_merged_object_ids": "10343620270;10343620448",
     "hs_object_id": "10343610802"
     },
     "createdAt": "2022-12-13T17:30:34.708Z",
     "updatedAt": "2022-12-13T17:33:58.486Z",
     "archived": false
    }​
    

Have fun building! — Jaycee

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

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

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

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