Automated Duplicate Merging in Bitrix24 CRM

Automated Duplicate Merging in Bitrix24 CRM A CRM with 12,000 contacts and 40% duplicates takes weeks to clean manually. Automated merging via the [API](https://dev.1c-bitrix.ru/rest_help/crm/crm_contact/crm_contact_merge.php) on PHP reduces the process to a few hours. But without proper rule con

Our competencies:

Frequently Asked Questions

Automated Duplicate Merging in Bitrix24 CRM

A CRM with 12,000 contacts and 40% duplicates takes weeks to clean manually. Automated merging via the API on PHP reduces the process to a few hours. But without proper rule configuration and relation handling, you risk losing activity history and deals. The mechanism uses the CCrmEntityMerger class, which transfers related objects and removes absorbed records. The order of operations is critical — the wrong sequence leads to broken references. Our engineers configure merges to keep history intact. On a recent project with 15,000 contacts and 35% duplicates, we cut merge time from two weeks to three hours, achieving 98% data integrity. Proper rules save up to 80% of the time, and the fix pays for itself within a month.

What do default merge rules do?

In CRM → Settings → Duplicates → Merge Rules, you define the logic for choosing values when fields conflict:

Rule Behavior
Primary record Takes the value from the selected 'main' card
More filled Takes a non-empty value; on conflict, from the primary
Merge Applicable for multiple fields (phones, email)
Last modified Takes the value from the record with a later modification date

For most tasks, set key identifiers (INN, phone, email) to 'merge'; status fields (responsible, stage) to 'primary record'; text notes to 'more filled'. If you are unsure, our engineers will help tailor the configuration to your CRM.

Programmatic merge via API

For mass cleanup, manual mode is not feasible. The REST method crm.contact.merge allows automatic merging of thousands of contacts:

// Merge: record 1001 absorbs 1002 and 1003 CRest::call('crm.contact.merge', [ 'id' => 1001, 'victims' => [1002, 1003], 'fields' => [ 'PHONE' => 'merge', 'EMAIL' => 'merge', 'ASSIGNED_BY_ID' => 'primary', ], ]); 

For companies, use crm.company.merge analogously. The method is synchronous; when merging more than 5 victims, it may time out — split into pairs. In the on-premise version on PHP:

$merger = new CCrmEntityMerger(CCrmOwnerType::Contact); $merger->Merge( 1001, [1002, 1003], $fields, $errorMessage ); 
Steps for a successful merge
  1. Create backups of tables b_crm_contact, b_crm_company, b_crm_deal, b_crm_activity, b_crm_timeline.
  2. Identify the primary record (most complete or with the highest number of deals).
  3. Run the merge for small victim groups (2-3 records) first.
  4. After completion, check related objects: deals, activities, tasks.
  5. For smart processes, update bindings via crm.item.update.

What does automation transfer?

The merge automatically transfers:

  • Deals (the CONTACT_ID field is updated)
  • Activities: calls, emails, meetings from b_crm_activity
  • Tasks via the b_tasks_member link
  • Timeline (b_crm_timeline)

What is NOT transferred automatically?

  • Links through user-defined smart process blocks (SPAs) — a separate update script is needed
  • External links from third-party integrations (data in custom tables)
  • Chat history in Open Lines — history is bound to the line, not the contact

How to minimize data loss risks?

Always back up the relevant tables before a mass merge. There is no built-in rollback — after a merge, absorbed records are marked deleted (DELETED=Y in b_crm_contact) but remain physically in the database for a few days until the recycle bin is cleared. The recovery window is: CRM → Settings → Recycle Bin — absorbed cards are available for restoration for 30 days (configurable). After restoration, links to the main record are not recreated — you must reassign them manually.

Manual vs. API merge comparison

Criterion Manual merge API merge
Speed ~2 minutes per pair 10 pairs per second
Volume Up to 50 records per session Thousands of records
Accuracy High but operator-dependent Predictable, rule-based
Control Full visual control Automatic, requires verification

API merging is 10× faster than manual and can handle up to 95% of duplicates in one pass. If your database exceeds 10,000 records, API merging is the only reasonable option. Order a merge setup from our engineers — they will adapt the rules to your business.

Why is testing the merge important?

Gartner notes that data cleaning improves forecast accuracy by 60%. Testing on live data with a backup uncovers problems before go-live. We always check activity transfer on a cloned database. Get a consultation on CRM optimization — our specialists will show you how to avoid data loss.

What is included in duplicate merge setup

  • Analysis of the current database for duplicates and their types
  • Configuration of merge rules according to your business processes
  • Testing on live data with a backup
  • Training your staff on duplicate handling
  • Documentation of the recovery procedure
  • 30-day post-setup support

We have been working with Bitrix24 for over a decade and have delivered more than 100 CRM cleanup projects. Our certified engineers guarantee data safety. Contact us for a free consultation — we will advise and select a strategy.