Use cases → Documents and Drive
Auto-label incoming files in Shared Drives using delegation
Apply labels to new files appearing in Shared Drives by polling with a service account and acting on recent changes.
| Who it is for | IT automation teams managing compliance or workflow labelling on Shared Drives. |
|---|---|
| APIs | Drive API |
| Typical scopes | drive |
The problem
Shared Drives are designed for team data, but manual labelling of new files is slow and unreliable. Automating this with domain-wide delegation ensures consistency, but the Drive API’s change tracking and permissions model introduce real operational complexity.
How it works
- Grant the service account delegated access with the 'drive' scope and add it as a member of each Shared Drive with at least Content Manager rights.
- Use the Drive API's Changes or Drive Activity endpoints to poll for newly created or uploaded files in each Shared Drive.
- For each new file, apply the required label using the Drive API's files.modifyLabels method.
- Log each change processed, storing the change token to ensure continuity between runs.
What changes
Files entering Shared Drives are labelled promptly and without relying on users, supporting audit or workflow processes with a consistent automation approach.
Questions people ask
Can I use push notifications instead of polling?
Push notifications for Drive changes are unreliable for Shared Drives due to occasional delivery gaps and require public endpoints. Polling with careful state management is more robust for delegated automation.
Does the service account need to be a manager of the Shared Drive?
Content Manager or above is required to apply labels. Viewer or Commenter permissions are insufficient, but adding the service account as a Manager is not strictly necessary unless it must alter drive membership.
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 guideRelated 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.