domainwidedelegation.comStart free

Use cases → Admin and governance

Bulk merge duplicate contacts using delegation

Merge duplicate contacts across many users’ address books by running a delegated automation with a service account.

Who it is forIT admins responsible for contact hygiene across multiple Workspace accounts.
APIsAdmin SDK
Typical scopesadmin.directory.user, admin.directory.user.readonly

The problem

Duplicate contacts creep in from imports, sync errors, and third-party integrations, causing confusion in autocomplete and mail routing. Manual cleanup does not scale, and native tools only operate per-user.

How it works

  1. Enumerate all target users via the Admin SDK.
  2. Impersonate each user with the service account and pull their contacts using the People API.
  3. Detect duplicates based on email addresses or phone numbers.
  4. Merge or update the contacts in-place, handling conflicts according to policy.
  5. Log the changes for review and error handling.

What changes

Contact lists across users are deduplicated in bulk, reducing confusion and misaddressed mail.

The trap in this one. The People API batchUpdateContacts endpoint enforces a 10-contact-per-request limit and silently skips over contacts that are concurrently edited or deleted, with no error in the batch response. This means some duplicates will persist unless you re-fetch and retry in a second pass, or explicitly diff the post-merge state.

Questions people ask

Can I merge contacts for users who have never logged in?

No; users must have an initial contacts profile. Accounts with no prior logins or initialised profiles will return empty results and cannot be updated.

How are merge conflicts handled?

If two contacts have conflicting fields, the People API keeps the most recently updated value unless you specify which fields to preserve. Always review the API’s merge behaviour and log changes.

Want this built?

This is a pattern we run in production. We will set up the delegation and build this on top of it — $500 per hour, most of it working the same day.

Talk to us Or read the setup guide

Related use cases

Audit which third-party apps can read your mail

List every OAuth grant across the domain and find the retired tools still holding access.

Automate joiners, movers and leavers

Create accounts, set group membership, provision Drive and hand over mailboxes without a manual checklist.

Continuously verify your delegation still works

A scheduled probe that proves every API still answers under every tenant, before a customer finds out otherwise.