domainwidedelegation.comStart free

Use cases → Documents and Drive

Run scheduled cleanups on shared drives across your domain

Automatically archive, delete, or move stale files in shared drives with a delegated service account on a fixed schedule.

Who it is forIT teams responsible for maintaining shared drive hygiene and compliance.
APIsDrive API
Typical scopesdrive

The problem

Shared drives accumulate redundant and outdated files, quickly exceeding storage quotas and making audits slow. Manual cleanup is sporadic and inconsistent, leading to missed retention policies and wasted space.

How it works

  1. Impersonate a durable admin user with full access to all relevant shared drives.
  2. List files by last modified or accessed date using the Drive API.
  3. Apply rules to flag, move, or delete files based on age, type, or location.
  4. Log actions and optionally notify file owners before destructive changes.
  5. Schedule the automation via a trusted orchestration system (e.g., Cloud Scheduler).

What changes

Shared drives stay within policy and storage limits, and regular reporting provides a clear audit trail of what was removed and why.

The trap in this one. Drive API's file listing for shared drives only returns files visible to the impersonated user at the time of the call. If permissions or membership changes are still propagating, files may be missed or wrongly flagged for deletion. This is silent—no error, just incomplete results. Always allow for permission propagation lag and validate with a secondary pass before destructive actions.

Watch it explained

“How to access Google Calendar API from NodeJs- Step by Step - Part 1” — Anand Kiran on YouTube. Third-party video, included because it covers this ground well. We are not affiliated with the channel.

Questions people ask

How do I ensure I see all files?

Impersonate a user with Manager access to each shared drive, and avoid running cleanup immediately after major permission changes—wait for propagation.

Can I recover deleted files?

If you move files to the shared drive trash, Managers can recover them until the trash is emptied. Permanent deletions are not reversible.

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

Create a client folder structure the moment a deal closes

Provision a consistent Drive folder tree, seeded with templates and shared with the right people, automatically.

Generate documents from a template and real data

Produce agreements, letters and reports from a Docs template with fields filled from your systems.

Sort incoming files into the right place automatically

Watch a drop folder, work out what each file is, and file it where it belongs with a consistent name.