Workflow AutomationOperationsn8nZapier

Merged Two Contacts and the Sync Broke? Fix the Old ID

A merge retires at least one record ID, and any integration that stored it can update the wrong record, fail, or create the duplicate again. HubSpot issues a new ID by default and keeps the old ones in hs_merged_object_ids, Salesforce deletes the losing record and sets MasterRecordId, and Pipedrive sends a delete event with merged_to_id. The fix is an alias table that maps every retired ID and external key to the surviving record.

Alexey YushkinFounder, GENERAL INFORMATICS2 min read

When you merge two contacts and the sync breaks, the integration is still holding a record ID that the merge retired. HubSpot creates a new ID by default and lists the old ones in hs_merged_object_ids, Salesforce deletes the losing record and points it at the survivor through MasterRecordId, and Pipedrive sends a delete event carrying merged_to_id. The fix is an alias table that maps every retired ID, and every external key that belonged to it, to the surviving record.

That second half, the external keys, is where the usual advice falls short. "Match on your own customer ID instead of the CRM's" is good advice until the two records you merged each had one.

What happens to the old ID when you merge two records?

It depends on the system. Each vendor retires the losing ID in its own way and publishes the survivor in a different field. Vendor documentation, checked November 2026:

SystemWhat happens to the IDsWhere the old-to-new link isTrap
HubSpotA new record ID by default. Accounts in the Primary ID Preservation beta keep the primary's IDhs_merged_object_ids on the survivor, plus merge webhook fieldsEven the winner's stored ID can be stale
SalesforceThe main record keeps its ID, the others are deletedMasterRecordId on the deleted recordA normal query does not return deleted rows
Shopify customersOne ID is kept, chosen by Shopify's rulesresultingCustomerId from the mutation, or the customers/merge webhookArgument order alone does not decide the winner
QuickBooks Online customersOne customer is merged into anotherqbo.customer.merged.v1 event: data.deletedid is the ID merged awayThe ID sits in a nested object that other events may not have
Pipedrive personsThe merge_with_id person stays, the other is removedmerged_to_id on the delete event, merged_from_id on the change eventThe merge arrives looking like a delete

HubSpot's behavior surprises people most, because both IDs you knew are replaced by a third. The change took effect on January 14, 2025 for all CRM object types, according to the developer announcement on HubSpot's community site. HubSpot staff said in that thread that fetching and updating by an old ID still works in the v3 and v4 APIs, and that this is not guaranteed in v1. So a HubSpot sync can keep writing happily while every local comparison of IDs fails. Your database has 101, the webhook says 303, and your code concludes it has met a new customer.

We would not lean on that forwarding for search or association calls. The documentation we read does not list which endpoints support it, and a user on HubSpot's community forum reports that searching by the old ID did not work. A lookup you own is cheaper than finding out.

Why does the duplicate come back after you merge it?

Because the source system still has two customers. This is the failure that a better ID lookup does not fix.

Say your accounting system has customers C-101 and C-102. They are the same person, entered twice. Your sync pushed both into the CRM and stamped each contact with its accounting number in a field called external_id. The example is illustrative, but the sequence is the same in any pair of systems:

  1. Someone in sales sees two contacts and merges them. The survivor has one external_id field, so it keeps C-101. The survivor no longer carries C-102.
  2. That evening, C-102 gets a new phone number in accounting. The sync does an upsert on external_id = C-102.
  3. Nothing matches. The upsert does what upserts do and creates a contact.
  4. Sales sees a duplicate and merges it again.

People describe this as the CRM "unmerging" records. Nothing was unmerged. The sync was told to make sure C-102 exists, and it did.

There are only two real endings. Merge C-101 and C-102 in accounting as well, so one key remains. Or, if the source cannot merge them, record that both keys belong to the same CRM contact, which a single-value field cannot express. That calls for a separate table with many keys to one record.

There is a quieter version when both keys do resolve. C-101 and C-102 now write to one contact, and each has its own address and phone. Whichever was processed last wins, and the contact flips back and forth as each one changes. If a field keeps alternating between two plausible values after a merge, look for two source records feeding one destination. It resembles a two-way sync overwriting good data, except the writes all go in one direction.

Is a merge a delete? Events that get misread

A merge reaches your automation as an event, or as nothing at all. Four shapes cause damage.

Pipedrive's delete that isn't one. Pipedrive's webhooks v2 guide documents merged_to_id as present only on delete events that were part of a merge, and merged_from_id as present only on change events that were part of one. An automation that listens for person deletes and deactivates the customer downstream will shut off someone who is still very much a customer. Check for merged_to_id first. If it is there, re-point. If it is absent, it is a real delete.

Shopify's merge event for a merge that failed. The sample payload in Shopify's webhook reference for customers/merge carries admin_graphql_api_customer_kept_id, admin_graphql_api_customer_deleted_id and, in that same sample, "status": "failed" with a merge_in_progress error. Both IDs are filled in. If you re-point on the IDs without reading status, you move a customer's orders in your own database for a merge that never happened. Read status and errors before you touch anything, and confirm the kept customer through the API.

Salesforce's silence. If you poll for changed contacts with an ordinary SOQL query, the survivor shows up as modified and the losing record simply stops appearing. The absence looks like a record that has not changed. Salesforce's own guide gives the query for finding merges. Its example selects only Id, so add the survivor:

SELECT Id, MasterRecordId
FROM Contact
WHERE IsDeleted = true
  AND MasterRecordId != null
  AND SystemModstamp > 2026-11-23T00:00:00Z

Run it through queryAll, because a plain query filters deleted rows out. Salesforce's merge() supports Leads, Contacts, Accounts, Person Accounts and Individuals, so run one per object you sync. Run it at least daily: the losing records sit in the Recycle Bin, and once they are purged the pointer goes with them. The same retention problem is covered in why deleted records don't sync.

HubSpot's two IDs for the winner. The contact.merge webhook defines primaryObjectId as the merge winner and newObjectId as the ID of the record after the merge. Store newObjectId. Treating the "winner" as the final ID is an easy mistake, since outside the beta the winner's ID changes too.

Build an alias table, not an ID column

Most syncs keep the link between systems in one column: CRM ID on the accounting row, or accounting ID on the CRM contact. One column means one value, and a merge needs room for several. Replace it with a small table:

systemkeycanonical_customerretired_atnote
crm101cust_72026-11-24merged into 303
crm202cust_72026-11-24merged into 303
crm303cust_7current
accountingC-101cust_7current, owns fields
accountingC-102cust_7current, linked only

Five rules make it hold up.

  1. Make system plus key unique, and never make canonical_customer unique. Many keys per customer is the point. A unique constraint on the customer side is what makes the second key fail to insert.
  2. Resolve every incoming ID here before any create. A retired ID still resolves. Only a key with no row at all may take the create branch, and that branch goes through your matching rules.
  3. Point aliases at your own ID, not at another alias. If 101 points to 303 and next month 303 is merged into 404, a chain of hops breaks at its weakest row. With a canonical ID of your own, the second merge only adds a row: 404 becomes the current key for cust_7.
  4. Handle both sides already existing. When the retired and surviving records map to two different canonical customers, move the keys of one to the other, re-parent its child rows in a single transaction, and log both IDs so the change can be reviewed.
  5. Name one key per source as the field owner. In the table, C-101 owns name and address. C-102 can attach invoices to cust_7 but does not write contact fields, which stops the flip-flop.

If your stack has no database, an n8n data table or an Airtable base with those five columns does the job at small volumes. Zapier users can resolve through Zapier Tables before the search-or-create step. What matters is that the lookup comes before the create.

How do you repair a sync after merges already happened?

Do not try to undo the merges. HubSpot says records cannot be unmerged, Shopify says a customer merge cannot be reversed, and Salesforce's undelete brings back the losing record while its child records stay with the survivor. Repair forward:

  1. Pause the create branch, not the whole sync. Updates to IDs that resolve can continue, and new duplicates are what you need to stop.
  2. Pull the merge history. In HubSpot, read hs_merged_object_ids for every contact that has a value. In Salesforce, run the query above with the earliest timestamp that still returns rows.
  3. Load each retired ID as an alias of its survivor.
  4. List the CRM records the sync created after each merge whose external key is missing from your alias table. Those are the likely resurrected duplicates. Once a person confirms one, link the key first, then merge the record. The other order starts the loop again.
  5. For keys in the source that share a customer, merge in the source if you can, and link if you can't.
  6. Turn creates back on and watch the count for a week.

Merges whose Salesforce rows were already purged have no pointer left. For those, fall back to exact matching on email or phone and send the rest to a person.

What to do next

Run one test this week, in a sandbox if you have one. Create two throwaway contacts in the source, let both sync, merge the CRM copies by hand, then edit each one in the source. Wait two cycles and count the records in the CRM. One means your sync survived the merge. Two means it is recreating the duplicates your team is cleaning up, and the alias table is the next thing to build.

Until it passes, ask the team to merge in the source first and the CRM second. If you would rather have the lookup, merge events and repair built once across your systems, that is part of our workflow automation systems work, and you can tell us which two systems disagree.

Frequently Asked Questions

Yes by default. HubSpot's knowledge base says a new unique Record ID is created for the merged record, and the previous IDs are listed in the Merged record IDs property. Accounts in the Primary ID Preservation for Merged Records beta keep the primary record's ID instead, as of September 2026.

Run queryAll, not query, and select Id and MasterRecordId from the object where IsDeleted is true, MasterRecordId is not null, and SystemModstamp is later than your last check. Id is the losing record and MasterRecordId is the survivor. A normal query leaves deleted records out.

The source system still holds two customers, and each one has its own external key. A single-value external ID field on the merged record can keep only one of them, so the next upsert for the other key finds nothing and creates a new record. Merge the records in the source too, or map both keys to the survivor.

No. The customer still exists under another ID. In Pipedrive, check for merged_to_id on a delete event before acting on it, because that field is present only when the delete was part of a merge. Deactivating on that event shuts off a live customer.

Usually not. HubSpot says records cannot be unmerged and Shopify says a customer merge cannot be reversed. Salesforce can undelete the losing record, but its documentation says the reparenting of child records cannot be undone.

SOURCES & CITATIONS

  1. Merge records — HubSpot Knowledge Basehttps://knowledge.hubspot.com/records/merge-records
  2. merge(), SOAP API Developer Guide — Salesforce Developershttps://developer.salesforce.com/docs/platform/api/guide/sforce-api-calls-merge.html
  3. Guide for Webhooks v2 — Pipedrivehttps://pipedrive.readme.io/docs/guide-for-webhooks-v2
  4. customerMerge, GraphQL Admin API — Shopifyhttps://shopify.dev/docs/api/admin-graphql/latest/mutations/customerMerge

About Alexey Yushkin

Alexey is the founder of GENERAL INFORMATICS LLC. He designs and ships AI and automation systems for businesses and operators across the US.

Connect on LinkedIn

Related reading

Want this kind of system in your business?

We build practical AI and automation systems for operators. Send us your current workflow and we will show you what to automate first.