domainwidedelegation.comStart free

Use casesEmail operations

Apply conditional forwarding rules via delegated automation

Set up and manage mailbox-specific forwarding logic based on message content, sender or other criteria using a service account.

Who it is forIT admins automating mailbox routing for teams or departments.
APIsGmail API
Typical scopesgmail.modify

The problem

Users need emails forwarded only when they match certain conditions, but manual filter management is error-prone and doesn’t scale. Delegated automation is required to apply and update rules across many mailboxes.

How it works

  1. Use a service account with domain-wide delegation and impersonate each target user.
  2. Fetch existing Gmail filters for the mailbox.
  3. Construct and insert new filters matching the required forwarding conditions.
  4. Remove or update filters as requirements change.

What changes

Conditional forwarding rules are consistent, centrally managed, and can be bulk-updated or revoked as policies evolve.

The trap in this one. The Gmail API does not allow inserting a forwarding filter unless the forwarding address has been verified in the target mailbox. If the automation tries to create the filter before the user has confirmed the forwarding address (or before the address is verified via the API), the request silently fails with a generic 400 error and the filter does not appear. This is not surfaced as a specific error and is easy to miss in logs, leading to forwarding rules that appear 'successfully applied' but do nothing.

Questions people ask

Can I add a forwarding address with the API?

You can programmatically add a forwarding address, but the user must confirm it via an email link before it becomes usable for filters. Automation cannot bypass this confirmation.

How do I know if a forwarding filter was actually created?

Always fetch and verify the mailbox's filters after creation. Do not trust a 200 response alone; the filter list must include the new rule and reference the verified forwarding address.

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

Draft replies automatically in a shared inbox

A delegated service account reads an incoming enquiry, drafts a researched reply in the mailbox, and leaves it for a human to approve and send.

Triage and route inbound mail across a domain

Classify every inbound message, label it, and forward the ones that matter to the person who owns them — without touching a single mail rule.

Send mail as a shared alias from automation

Deliver notifications, confirmations and campaign replies from a branded address like support@ or updates@ without a human in the loop.