Set up notifications for changes in resource data
Change notifications enable applications to receive alerts when a Microsoft Graph resource they're interested in changes; that is, created, updated, or deleted. Microsoft Graph sends notifications to the specified client endpoint, and the client service processes the notifications according to the business requirements. For example, the service may fetch more data, update its cache and views, and so on.
Why get change notifications?
Change notifications follow an event-driven model where customers receive alerts when changes occur instead of them polling Microsoft Graph. Depending on your business logic, change notifications are suitable when:
- You're subscribing to a resource that changes frequently.
- You need to react to changes in near real-time.
- You want to avoid frequently polling Microsoft Graph which might cause you to hit the throttling limits.
Types of change notifications
Microsoft Graph supports three types of change notifications:
- Basic notifications: Change notifications that don't contain resource data other than the id of the resource that changed. All Microsoft Graph resources support basic notifications. When an app receives a basic notification, the service can use the id to query to changed object.
- Rich notifications: Change notifications that include the resource data of the object that changed. For the list of Microsoft Graph resources that support rich notifications, see supported resources.
- Lifecycle notifications: Notifications that alert the customer when they are at risk of missing change notification due to the lifecycle of their subscription. For more information about lifecycle notifications, see Lifecycle notifications.
Supported resources
An app can subscribe to changes on the Microsoft Graph resources listed in the table, which also indicates the limits that apply for subscriptions to the resources. When any limit is exceeded, attempts to create a subscription will result in an 403 Forbidden
error response. The message property of the error response will explain the limit that has been exceeded.
Note
Subscriptions to resources marked with an asterisk (*) are available on the /beta
endpoint only.
Resource | Supported resource paths | Limitations |
---|---|---|
Cloud printing printer | Changes when a print job is ready to be downloaded (jobFetchable event): /print/printers/{id}/jobs |
- |
Cloud printing printTaskDefinition | Changes when there is a valid job in the queue (jobStarted event): /print/printtaskdefinition/{id}/tasks |
- |
driveItem on OneDrive (personal) | Changes to content within the hierarchy of any folder: /users/{id}/drive/root |
- |
driveItem on OneDrive for Business | Changes to content within the hierarchy of the root folder: /drives/{id}/root , /users/{id}/drive/root |
- |
group | Changes to all groups: /groups Changes to a specific group: /groups/{id} Changes to owners of a specific group: /groups/{id}/owners Changes to members of a specific group: /groups/{id}/members |
Maximum subscription quotas: Not supported for Azure AD B2C tenants. A known issue for the subscription changeType. |
list under a SharePoint site | Changes to content within the list: /sites/{site-id}/lists/{list-id} |
- |
Microsoft 365 group conversation | Changes to a group's conversations: groups/{id}/conversations |
- |
Outlook message | Changes to all messages in a user's mailbox: /users/{id}/messages , /me/messages Changes to messages in a user's Inbox: /users/{id}/mailFolders('inbox')/messages , /me/mailFolders('inbox')/messages |
A maximum of 1,000 active subscriptions per mailbox for all applications is allowed. |
Outlook event | Changes to all events in a user's mailbox: /users/{id}/events , /me/events |
A maximum of 1,000 active subscriptions per mailbox for all applications is allowed. |
Outlook personal contact | Changes to all personal contacts in a user's mailbox: /users/{id}/contacts , /me/contacts |
A maximum of 1,000 active subscriptions per mailbox for all applications is allowed. |
Security alert | Changes to a specific alert: /security/alerts/{id} Changes to filtered alerts: /security/alerts/?$filter={parameters} |
- |
Teams callRecord | Changes to all call records: /communications/callRecords |
Maximum subscription quotas: |
Teams chat | Changes to any chat in the tenant: /chats Changes to a specific chat: /chats/{id} |
Maximum subscription quotas: |
Teams chatMessage | Changes to chat messages in all channels in all teams: /teams/getAllMessages Changes to chat messages in a specific channel: /teams/{id}/channels/{id}/messages Changes to chat messages in all chats: /chats/getAllMessages Changes to chat messages in a specific chat: /chats/{id}/messages Changes to chat messages in all chats a particular user is part of: /users/{id}/chats/getAllMessages |
Maximum subscription quotas: |
Teams channel | Changes to channels in all teams: /teams/getAllChannels Changes to channel in a specific team: /teams/{id}/channels |
Maximum subscription quotas: |
Teams conversationMember | Changes to membership in a specific team: /teams/{id}/members Changes to membership in all channels under a specific team: teams/{id}/channels/getAllMembers Changes to membership in a specific chat: /chats/{id}/members Changes to membership in all chats: /teams/getAllMembers |
Maximum subscription quotas: |
Teams onlineMeeting * | Changes to an online meeting: /communications/onlineMeetings/?$filter=JoinWebUrl eq {joinWebUrl} |
|
Teams presence * | Changes to a single user's presence: /communications/presences/{id} Changes to multiple user presences: /communications/presences?$filter=id in ({id},{id}...) |
|
Teams team | Changes to any team in the tenant: /teams Changes to a specific team: /teams/{id} |
Maximum subscription quotas: |
todoTask | Changes to all task in a specific task list: /me/todo/lists/{todoTaskListId}/tasks |
- |
user | Changes to all users: /users Changes to a specific user: /users/{id} |
Maximum subscription quotas: Not supported for personal Microsoft accounts like outlook.com. Not supported for Azure AD B2C tenants. A known issue for the subscription changeType. |
The following resources support rich notifications (notifications with resource data):
- Outlook event
- Outlook message
- Outlook personal contact
- Teams chat
- Teams chatMessage
- Teams channel
- Teams conversationMember
- Teams onlineMeeting *
- Teams presence *
- Teams team
Receiving change notifications
Microsoft Graph can deliver change notifications to clients via the following channels.
- Webhooks. For more information, see Receive change notifications through webhooks.
- Azure Event Hubs. For more information, see Receive change notifications through Azure Event Hubs.
Subscription lifetime
Subscriptions have a limited lifetime. Apps need to renew their subscriptions before the expiration time; Otherwise, they need to create a new subscription. Apps can also unsubscribe at any time to stop getting change notifications.
The following table shows the maximum expiration times for subscriptions per resource in Microsoft Graph.
Resource | Maximum expiration time |
---|---|
Security alert | 43,200 minutes (under 30 days) |
Teams callRecord | 4,230 minutes (under 3 days) |
Teams channel | 60 minutes (1 hour) |
Teams chat | 60 minutes (1 hour) |
Teams chatMessage | 60 minutes (1 hour) |
Teams conversationMember | 60 minutes (1 hour) |
Teams onlineMeeting | 4,320 minutes (3 days) |
Teams team | 60 minutes (1 hour) |
Group conversation | 4,230 minutes (under 3 days) |
OneDrive driveItem | 42,300 minutes (under 30 days) |
SharePoint list | 42,300 minutes (under 30 days) |
Outlook message, event, contact | 4,230 minutes (under 3 days) |
user, group, other directory resources | 41,760 minutes (under 29 days) |
onlineMeeting | 4,230 minutes (under 3 days) |
presence | 60 minutes (1 hour) |
Print printer | 4,230 minutes (under 3 days) |
Print printTaskDefinition | 4,230 minutes (under 3 days) |
todoTask | 4,230 minutes (under 3 days) Webhooks for this resource are only available in the global endpoint and not in the national clouds. |
baseTask (deprecated) | 4,230 minutes (under 3 days) |
Note: Existing applications and new applications should not exceed the supported value. In the future, any requests to create or renew a subscription beyond the maximum value will fail.
Managing subscriptions
Clients can create subscriptions, renew subscriptions, and delete subscriptions. Then while the subscription is valid and when changes occur in the subscribed resource, Microsoft Graph sends change notifications to the specified notification endpoint.
You manage the subscription using the subscription resource type and its related methods. While the subscription is valid and changes occur in the subscribed resource, Microsoft Graph sends a change notification in a structure defined in the changeNotificationCollection resource type.
For more information about managing subscriptions for the different delivery channels using Microsoft Graph, see the following articles.
Code samples
The following code samples are available on GitHub.
- Microsoft Graph Training Module - Using Change Notifications and Track Changes with Microsoft Graph
- Microsoft Graph Webhooks Sample for Node.js
- Microsoft Graph Webhooks Sample for ASP.NET Core
- Microsoft Graph Webhooks Sample for Java Spring
Latency
The following table lists the latency to expect between an event happening in the service and the delivery of the change notification.
Resource | Average latency | Maximum latency |
---|---|---|
alert 1 | Less than 3 minutes | 5 minutes |
callRecord | Less than 15 minutes | 60 minutes |
channel | Less than 10 seconds | 60 minutes |
chat | Less than 10 seconds | 60 minutes |
chatMessage | Less than 10 seconds | 1 minute |
contact | Unknown | Unknown |
conversation | Unknown | Unknown |
conversationMember | Less than 10 seconds | 60 minutes |
driveItem | Less than 1 minute | 5 minutes |
event | Unknown | Unknown |
group | Less than 2 minutes | 15 minutes |
list | Less than 1 minute | 5 minutes |
message | Unknown | Unknown |
onlineMeeting | Less than 10 seconds | 1 minute |
presence | Less than 10 seconds | 1 minute |
printer | Less than 1 minute | 5 minutes |
printTaskDefinition | Less than 1 minute | 5 minutes |
team | Less than 10 seconds | 60 minutes |
todoTask | Less than 2 minutes | 15 minutes |
user | Less than 2 minutes | 15 minutes |
1 The latency provided for the alert resource is only applicable after the alert is created. It doesn't include the time it takes for a rule to create an alert from the data.
Deployment resources
- Get change notifications through webhooks
- Get change notifications through Azure Event Hubs
- Rich notifications (notifications with resource data)
- Lifecycle notifications
- Tutorials
See also
Feedback
Submit and view feedback for