logo
search
Others

How to Configure WebSocket Notifications for OneDrive File Changes

Partner EditorPartner Editor Oct 1, 2026 868 views

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.

How to Configure WebSocket Notifications for OneDrive File Changes
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.
Before you start

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.

Solution 1Recommended

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.

1
Register your application

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.

2
Set up a notification endpoint

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.

3
Create the subscription

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'.

4
Handle incoming notifications

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.

Use Microsoft Graph API for OneDrive Change Notifications
Developer Resources: For detailed implementation guidance, payload structures, and troubleshooting, visit the Microsoft 365 Developer Community or the Microsoft Q&A forums.
Free Microsoft Office alternative

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. 1. Download the installer: Visit the official WPS Office website and click the free download button for your operating system.
  2. 2. Install the software: Run the downloaded executable file and follow the straightforward on-screen prompts to complete the setup.
  3. 3. Start editing: Launch WPS Office, open your local or cloud-synced documents, and enjoy a seamless editing experience.
Seamlessly open, edit, and save files synced via your custom OneDrive integrations.Highly compatible with Microsoft Word, Excel, and PowerPoint file formats (.docx, .xlsx, .pptx).Lightweight installation and resource-friendly performance, ideal for developer environments.Free to use with a familiar, easy-to-navigate tabbed user interface.
microsoft office alternative - wps office

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.