Sometimes, multiple units with the same contact details, such as email or phone number, are accidentally saved. This can cause issues in processes that search or filter by these fields. This guide shows you how to configure a Unit Pipeline job to find and merge all duplicates.
Merge by email
The steps below show how to find all duplicates on the account based on the email address, and merges them.
- Add a Find duplicates step
Choose the type of duplicate to detect; email or phone. This step will get all units with duplicate values from the account. - Add a Merge units step
- Group by expression
- Use our standard syntax here, for example: {{this.email}}.
- Merge Target
- Select whether the newest or oldest unit should be the target.
- The other unit(s) will become the source.
- Merge Action
- Currently, the only available option is Overwrite old unit data, which updates the target using data from the source(s).
- After merge have source
- These are the units that are merged into the target.
- Choose what should happen to them after the merge:
- Remove from account
- Remove from loaded resource
- Save to a new resource
- For our purpose, select Remove from account.
- After merge have target
- Choose what to do with the resulting target unit.
- Select Save to new resource so the merged units are available later in the process if needed.
- Group by expression
- Add a Save to account step
- This step saves the updated units to the account.

Merge by metadata
Merging can also be done by metadata key and instead of searching for duplicates on the account based on the email or phone number, you can load units from a group or a resource.
- Add a Find units step
- Decide if you want to get the units from a group or a resource. In the example below, we’ve selected Retrieved followed by From group as the source.
- Add a Merge Units step
- Use our standard syntax here, for example: {{this.metadata.customer_id}}
- All other settings are the same as the steps above.
