Use cases → Documents and Drive
Monitoring new files in a shared Drive folder
How to track and respond to new files uploaded in a Google Drive shared folder using push notifications and incremental sync, with real-world caveats.
| Who it is for | Workspace automation engineers building file intake or processing systems. |
|---|---|
| APIs | Drive API |
| Typical scopes | drive |
The problem
Teams often need to trigger workflows when new files arrive in a shared Drive folder, but relying solely on manual polling is inefficient and can cause missed or delayed processing. The Drive API offers push notifications, but these are stateful and have reliability limitations. Missing a notification or losing track of the current state can result in unprocessed files, with no built-in recovery.
How it works
- Use the Drive API's files.watch endpoint to register a webhook notification channel on the target folder.
- Store the returned startPageToken after the initial sync and use it for incremental changes tracking.
- On receiving push notifications, use files.list with the saved pageToken to fetch new or changed files since the last checkpoint.
- Periodically refresh the watch channel before it expires, and update the pageToken with each sync.
- Implement retry logic for failed file transfers and handle notification channel expiration events by falling back to a full folder scan using the latest saved pageToken.
What changes
File ingestion is event-driven and near real-time, with missed changes detected via incremental resync. This reduces latency and manual intervention compared to polling the folder contents.
Questions people ask
How often should I refresh the watch channel?
Watch channels typically expire after a few days; refresh at least every 24 hours and always handle the 'stop' notification to avoid missing changes.
What happens if the service account loses access to the folder?
Notifications will silently stop and incremental syncs will fail. Always validate access before re-registering channels and during resync.
Can I guarantee zero missed files using this method?
No; you must combine push notifications with periodic full or incremental scans using the saved pageToken to account for missed events or channel interruptions.
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.