How it works
Microsoft Graph delivers change notifications by sending HTTP POST requests to your endpoint when a subscribed resource changes. The flow is:- You create a Microsoft Graph subscription with your Nango webhook URL as the
notificationUrl - Microsoft sends a one-time validation request to confirm ownership of the URL — Nango handles this automatically
- When a subscribed resource changes (e.g. a user is updated, a message is received), Microsoft POSTs a notification to your Nango webhook URL
- Nango validates the notification using the
clientStatesecret, matches it to the correct connection using thetenantId, and forwards it to your app
tenantId from the notification payload, matched against the tenantId stored in each connection’s config.
Setup
1. Get your Nango webhook URL
- Go to the Nango dashboard and navigate to the Integrations tab
- Select your Microsoft (Client Credentials) integration
- Go to the Settings sub-tab
- Copy the Webhook URL — it will look like
https://api.nango.dev/webhook/<ENV-UUID>/microsoft-oauth2-cc
2. Set a webhook secret in Nango
Microsoft Graph lets you pass aclientState value in each subscription. Nango uses this to validate incoming notifications.
- In the Nango dashboard, go to the Settings sub-tab for your integration
- Under Webhook Configuration, enter a secret string in the Webhook Secret field
- Click Save, you’ll use this same value as
clientStatewhen creating subscriptions
3. Create a Microsoft Graph subscription
Create a subscription via the Nango proxy. SetnotificationUrl to your Nango webhook URL (copied from the Settings tab) and clientState to the secret you configured in step 2. See the Subscription lifetime docs for maximum expiration limits per resource type:
- cURL
- Node
validationToken query parameter. Nango responds automatically, no action required on your part.
You can automate subscription creation for new connections using a post-connection-creation script:
4. Renew subscriptions before they expire
Microsoft Graph subscriptions expire and must be renewed before expiry. Use a Nango sync to renew them automatically — adjust the frequency to match the expiration window of the resource you are subscribing to:5. Handle forwarded webhooks
When a Microsoft Graph notification arrives, Nango validates theclientState, matches the notification to the correct connection via tenantId, and forwards the payload to your app. The forwarded payload looks like this:
1d) as a safety net for any missed notifications.
Connection matching
Nango uses thetenantId from the notification payload to find the matching connection. The tenantId is automatically stored in each connection’s config when the connection is created.
Supported resources
Microsoft Graph supports subscriptions for a wide range of resources. Common examples:| Resource | changeType values |
|---|---|
users | created, updated, deleted |
groups | created, updated, deleted |
users/{id}/messages | created, updated, deleted |
users/{id}/events | created, updated, deleted |
users/{id}/drive/root | updated |
/teams/{id}/channels | created, deleted |