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.
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:
| System | What happens to the IDs | Where the old-to-new link is | Trap |
|---|---|---|---|
| HubSpot | A new record ID by default. Accounts in the Primary ID Preservation beta keep the primary's ID | hs_merged_object_ids on the survivor, plus merge webhook fields | Even the winner's stored ID can be stale |
| Salesforce | The main record keeps its ID, the others are deleted | MasterRecordId on the deleted record | A normal query does not return deleted rows |
| Shopify customers | One ID is kept, chosen by Shopify's rules | resultingCustomerId from the mutation, or the customers/merge webhook | Argument order alone does not decide the winner |
| QuickBooks Online customers | One customer is merged into another | qbo.customer.merged.v1 event: data.deletedid is the ID merged away | The ID sits in a nested object that other events may not have |
| Pipedrive persons | The merge_with_id person stays, the other is removed | merged_to_id on the delete event, merged_from_id on the change event | The 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:
- Someone in sales sees two contacts and merges them. The survivor has one
external_idfield, so it keeps C-101. The survivor no longer carries C-102. - That evening, C-102 gets a new phone number in accounting. The sync does an upsert on
external_id = C-102. - Nothing matches. The upsert does what upserts do and creates a contact.
- 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:
| system | key | canonical_customer | retired_at | note |
|---|---|---|---|---|
| crm | 101 | cust_7 | 2026-11-24 | merged into 303 |
| crm | 202 | cust_7 | 2026-11-24 | merged into 303 |
| crm | 303 | cust_7 | current | |
| accounting | C-101 | cust_7 | current, owns fields | |
| accounting | C-102 | cust_7 | current, linked only |
Five rules make it hold up.
- Make
systempluskeyunique, and never makecanonical_customerunique. Many keys per customer is the point. A unique constraint on the customer side is what makes the second key fail to insert. - 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.
- 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.
- 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.
- 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:
- Pause the create branch, not the whole sync. Updates to IDs that resolve can continue, and new duplicates are what you need to stop.
- Pull the merge history. In HubSpot, read
hs_merged_object_idsfor every contact that has a value. In Salesforce, run the query above with the earliest timestamp that still returns rows. - Load each retired ID as an alias of its survivor.
- 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.
- For keys in the source that share a customer, merge in the source if you can, and link if you can't.
- 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
SOURCES & CITATIONS
- Merge records — HubSpot Knowledge Basehttps://knowledge.hubspot.com/records/merge-records
- merge(), SOAP API Developer Guide — Salesforce Developershttps://developer.salesforce.com/docs/platform/api/guide/sforce-api-calls-merge.html
- Guide for Webhooks v2 — Pipedrivehttps://pipedrive.readme.io/docs/guide-for-webhooks-v2
- 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.
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.
