How to Configure WebSocket Notifications for OneDrive File Changes
Question details
The user wants to know how to configure WebSocket or webhook notifications to detect file changes in OneDrive using Microsoft 365 development APIs.

- Product
- Microsoft OneDrive / Microsoft 365
- Device & OS
- not provided
- Scenario
- Developing an application that requires real-time alerts when files are created, modified, or deleted in a user's OneDrive account.
- Observed behavior
- The user needs to identify the correct API endpoints and Microsoft Graph methods to successfully implement real-time file change tracking.
Ensure you have access to the Microsoft Entra admin center for app registration and possess a basic understanding of REST APIs and Microsoft Graph subscriptions.
Use Microsoft Graph API for OneDrive Change Notifications
Microsoft Graph provides change notifications (webhooks) that can alert your application when file modifications occur in OneDrive.
While OneDrive does not natively maintain persistent WebSocket connections directly to client browsers for file changes, developers can use Microsoft Graph webhooks. Your backend server receives the HTTP POST webhook from Microsoft Graph and can then forward that event to your frontend application using your own WebSocket implementation.
Log in to the Microsoft Entra admin center, navigate to App registrations, and create a new app. Grant it the necessary API permissions such as Files.Read or Files.ReadWrite.
Create a publicly accessible web API endpoint on your server that can receive HTTP POST requests. It must be able to return the validation token sent by Microsoft Graph during the initial setup.
Send a POST request to the Microsoft Graph `/subscriptions` endpoint. Set the 'resource' property to the target OneDrive driveItem (e.g., `/me/drive/root`) and 'changeType' to 'updated'.
Once subscribed, your endpoint will receive payloads whenever a file changes. You can then broadcast these changes to your frontend clients via your own WebSocket server.

Looking for a Developer-Friendly Office Suite?
While you build and integrate advanced Microsoft Graph APIs for OneDrive, consider equipping your team with WPS Office. It provides robust document processing, native compatibility with Microsoft Office formats, and cloud integration without the heavy system overhead.
- 1. Download the installer: Visit the official WPS Office website and click the free download button for your operating system.
- 2. Install the software: Run the downloaded executable file and follow the straightforward on-screen prompts to complete the setup.
- 3. Start editing: Launch WPS Office, open your local or cloud-synced documents, and enjoy a seamless editing experience.

Frequently Asked Questions
Does Microsoft Graph support direct WebSocket connections for OneDrive?
No, Microsoft Graph primarily uses HTTP webhooks for OneDrive change notifications. However, you can use Microsoft Graph Data Connect or route webhook payloads through your own backend server to push real-time updates to clients via WebSockets.
Where can I find development support for Microsoft 365 APIs?
You can find official documentation on Microsoft Learn, and seek community support by posting your technical questions on the Microsoft 365 Developer Community or the Microsoft Q&A platform under the relevant tags.
Do Microsoft Graph webhook subscriptions for OneDrive expire?
Yes, webhook subscriptions have an expiration time (typically up to 30 days for OneDrive resources). Your backend application must proactively send a PATCH request to renew the subscription before it expires to continue receiving change notifications.




