Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Prerequisites

  1. Read this document to get a fundamental understanding of how to create Graph Subscriptions.
  2. Access to a Shared Mailbox (the example below sets up notifications for a Shared Mailbox)

1. How-to: - Create a change notificaiton subscription for email in a Shared Mailbox

You can create a subscription by sending a POST request to the subscriptions endpoint and in the Request body passing the proper JSON. Below is an example of how the JSON should be formated.

{
   "changeType": "created",
   "notificationUrl": "<https://YOUR URL THAT WILL BE CALLED>",
   "resource": "/users/PoCSMB@XXX.onmicrosoft.com//mailfolders('inbox')/messages",
   "expirationDateTime":"2023-04-04T11:00:00Z",
   "clientState": "secretClientValue",
   "latestSupportedTlsVersion": "v1_2"
}

Important Clarification You will make a POST request to the https://graph.microsoft.com/v1.0/subscription endpoint and pass in the a request body that is formatted as outlined above. For more information on how your notificationUrl should properly respond, refer to this documentation

If the Request body is properly formated, and your notificaitonUrl endpoint properly handles the Validation Token and responds with a 202, the subscription will be created and Graph will respond with these details: CreateSub

How to get a list of Graph subscriptions

This will come in handy to check to see what subscriptions are still active. Keep in mind that the various change notifications can have different expiry max timeframes. If you need your subscription to run longer than the max limit, you will need to impliment logic to reset the subscription to a new expiration.

  1. Navigate to Graph Explorer and make sure you are logged-in to an account that has permissions to Graph.

  2. Send a GET request to the subscriptions endpoint https://graph.microsoft.com/v1.0/subscriptions. Below is an example. If you have any subscriptions they will be noted in the Response Preview Window. GetSubs

Resources

How to properly respond to Graph change notifications