domainwidedelegation.comGet it set up

Use casesAdmin and governance

Automate alerts for Workspace security incidents

Detect and notify on critical security events in Google Workspace by polling the audit log and sending targeted alerts, without relying on admin email forwarding.

Who it is forSecurity operations teams responsible for monitoring Workspace tenant activity.
APIsAdmin SDK, Gmail API
Typical scopesadmin.reports.audit.readonly, gmail.send

The problem

Security incidents like suspicious logins, data exfiltration, or privilege escalations are written to the audit logs, but native alerting is limited and often misses context. Relying on admin email notifications leaves gaps and requires manual triage.

How it works

  1. Poll the Admin SDK Reports API for new audit events using a delegated service account.
  2. Parse and classify events to identify those matching incident criteria (e.g. login from new location, sensitive file shared externally).
  3. Send a summary alert via Gmail API to a security inbox or on-call address.
  4. Log all events and alerts for later investigation.

What changes

Security teams get actionable alerts with richer context and less noise, and the audit log is mined for patterns that native alerts miss.

The trap in this one. Audit event delivery in the Reports API is delayed by several minutes and not strictly ordered; polling at a high frequency can result in duplicate alerts for the same incident. De-duplication must key on eventId, not timestamp, as out-of-order delivery is common and subtle—otherwise, some incidents will be missed or double-reported, especially during high activity.

Questions people ask

Can I get real-time alerts using this method?

No. The Reports API delivers events with a delay (often 2–10 minutes), and there is no webhook. Polling is as close as possible to real-time.

How do I avoid duplicate alerts?

Track processed eventIds and persist this state between runs. Timestamps are unreliable for deduplication due to out-of-order event delivery.

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

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.

Reduce an over-broad delegation grant safely

Find out which scopes your automation genuinely uses, then cut the grant down to them.