How it works
The Google Drive API supports two kinds of notification channels:changes.watch— watches every change across the user’s Drive (or one shared drive). This is the recommended approach.files.watch— watches a single file for changes. Use this when you only care about one specific file; see the note at the end of step 2.
- You call
changes.watch, passing your Nango webhook URL as the channeladdress. - Google creates a notification channel and sends an initial
syncmessage to your URL. - When anything changes in the watched Drive, Google sends a notification to Nango.
- Nango matches the notification to the correct connection and forwards it to your app.
Setup
1. Get your webhook URL
Copy the webhook URL from your Google Drive integration page in the Nango dashboard, under the Webhook URL section. This is the HTTPS URL you will use as the channeladdress when creating notification channels.
2. Create a notification channel (watch the Drive)
You can automate creating the channel for new connections with a post-connection-creation script:- address — Your Nango webhook URL from the dashboard.
- id — A unique string (e.g. UUID) identifying this channel; max 64 characters. It is echoed in
X-Goog-Channel-IDon every notification. - expiration — (Optional) Unix timestamp in milliseconds when the channel should stop sending notifications. Drive’s own maximum is 7 days for
changes.watch; if you request longer, Google caps it. If omitted, the default is 1 hour after the current time.
To watch a single file instead of the whole Drive, call
files.watch instead: drop the pageToken param and startPageToken call, and set endpoint: "/drive/v3/files/${fileId}/watch" (24h max expiration instead of 7 days).3. Renew the notification channel
Google does not renew channels automatically. When a channel is close to its expiration, you must create a new channel by callingchanges.watch again with a new unique id and a fresh pageToken. After the new channel is created successfully, stop the old channel so only one remains active. See Renew notification channels.
You can use a Nango sync with a suitable frequency (e.g. every day, given the 7-day maximum for changes.watch) to renew the watch before it expires:
4. Stop notifications on connection deletion
If a connection is deleted in Nango but the channel remains active, Google may continue sending notifications until the channel expires. To stop notifications immediately for a deleted connection, callchannels.stop before deletion.
You can automate this with a pre-connection-deletion lifecycle event. This uses the googleDriveChannelId and googleDriveWatchResourceIds stored in metadata during channel creation (step 2) and renewal (step 3):
5. Handle forwarded webhooks
When a Drive notification arrives, Nango matches it to the correct connection and forwards it to your system. Notification messages have no body; Google sends only HTTP headers. Nango forwards those headers in the payload. Example structure:
Notifications do not include the changed files themselves — call
changes.list with a stored pageToken to fetch what changed since your last check, then save the newStartPageToken it returns for the next call. After receiving the webhook, trigger your sync or API calls for that connection:
1d or 1h) as a safety net for missed notifications.
If you prefer Nango to automatically run a sync when the webhook arrives (instead of forwarding it to your app), you can enable webhook processing in a sync script using
webhookSubscriptions and onWebhook. For Google Drive, subscribe to '*' and use the forwarded headers (e.g. x-goog-resource-state, x-goog-resource-uri) to decide what to fetch.See: Real-time syncsConnection matching
Google Drive has no built-in identifier Nango can derive automatically, so you must always register the watched resource yourself. Nango matches incoming Drive notifications by resource ID, againstmetadata.googleDriveWatchResourceIds — the value you store via nango.updateMetadata() in your post-connection-creation script (step 2) and renewal sync (step 3).
- The value must be a JSON
string[]. Store theX-Goog-Resource-IDstring exactly as Google sends it. - Update metadata from your own Nango functions via
nango.updateMetadata(), or manually via the update metadata API.
googleDriveWatchResourceIds (e.g. two connections watching the same shared drive), every matching connection is included. Nango forwards the webhook once per matching connection, with the appropriate connectionId.
Rollback strategy
To stop webhooks:- Call
channels/stopfor each channel you created (using the channelidandresourceId), or - Let the channel expire by not renewing it.
id and your Nango webhook URL as address.