Corsair
PluginsGoogle Drive

Google Drive Webhooks

All available Google Drive webhook events

The Google Drive plugin automatically handles incoming webhooks from Google Drive. Configure Google Drive push notifications to receive real-time updates when files or folders change.

New to Corsair? Learn about core concepts like webhooks, hooks, and multi-tenancy before setting up webhook handlers.

Full Implementation: For the complete, up-to-date list of all webhook events and their implementations, see the Google Drive plugin source code on GitHub.

Setup

Configure your webhook endpoint to handle Google Drive events:

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Available Webhooks

driveChanged

driveChanged

Event Type: Drive Changed

Fires when a file or folder is created, updated, deleted, or trashed. The handler automatically determines the resource type and returns the appropriate event.

When it fires: A file or folder is created, modified, trashed, or deleted in the connected Google Drive.

Possible event types in result.data.type:

  • fileChanged — A file was created, updated, deleted, or trashed
  • folderChanged — A folder was created, updated, deleted, or trashed

Example Usage:

corsair.ts
googledrive({
    webhookHooks: {
        driveChanged: {
            after: async (ctx, result) => {
                console.log(`Drive event: ${result.data?.type}`);
                
                if (result.data?.type === 'fileChanged') {
                    console.log(`File ${result.data.fileId} was ${result.data.changeType}`);
                    console.log(`Path: ${result.data.filePath}`);
                }
                
                if (result.data?.type === 'folderChanged') {
                    console.log(`Folder ${result.data.folderId} was ${result.data.changeType}`);
                }
            },
        },
    },
})

See Webhooks for more details on webhook concepts and Hooks for the complete hooks documentation.