Skip to main content

graph subscription add

Creates a Microsoft Graph subscription


m365 graph subscription add [options]


-r, --resource <resource>

The resource that will be monitored for changes.

-c, --changeTypes <changeTypes>

The type of change in the subscribed resource that will raise a notification. The supported values are: created, updated, deleted. Multiple values can be combined using a comma-separated list.

-u, --notificationUrl <notificationUrl>

The URL of the endpoint that will receive the notifications. This URL must use the HTTPS protocol.

-e, --expirationDateTime [expirationDateTime]

The date and time when the webhook subscription expires. The time is in UTC, and can be an amount of time from subscription creation that varies for the resource subscribed to. If not specified, the maximum allowed expiration for the specified resource will be used.

-s, --clientState [clientState]

The value of the clientState property sent by the service in each notification. The maximum length is 128 characters.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.


Runs command with verbose logging.


Runs command with debug logging.


On personal OneDrive, you can subscribe to the root folder or any subfolder in that drive. On OneDrive for Business, you can subscribe to only the root folder.

Notifications are sent for the requested types of changes on the subscribed folder, or any file, folder, or other driveItem instances in its hierarchy. You cannot subscribe to drive or driveItem instances that are not folders, such as individual files.

In Outlook, delegated permission supports subscribing to items in folders in only the signed-in user's mailbox. That means, for example, you cannot use the delegated permission Calendars.Read to subscribe to events in another user’s mailbox.

To subscribe to change notifications of Outlook contacts, events, or messages in shared or delegated folders:

  • Use the corresponding application permission to subscribe to changes of items in a folder or mailbox of any user in the tenant.
  • Do not use the Outlook sharing permissions (Contacts.Read.Shared, Calendars.Read.Shared, Mail.Read.Shared, and their read/write counterparts), as they do not support subscribing to change notifications on items in shared or delegated folders.


Create a subscription

m365 graph subscription add --resource "me/mailFolders('Inbox')/messages" --changeTypes "updated" --notificationUrl "" --expirationDateTime "2016-11-20T18:23:45.935Z" --clientState "secretClientState"

Create a subscription on multiple change types

m365 graph subscription add --resource groups --changeTypes "updated,deleted" --notificationUrl "" --expirationDateTime "2016-11-20T18:23:45.935Z" --clientState "secretClientState"

Create a subscription using the maximum allowed expiration for Group resources

m365 graph subscription add --resource groups --changeTypes "updated" --notificationUrl ""


"id": "d2df2c16-26ee-4431-ab22-3b133556fb26",
"resource": "groups",
"applicationId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"changeType": "updated",
"clientState": "some secret value",
"notificationUrl": "",
"notificationQueryOptions": null,
"lifecycleNotificationUrl": null,
"expirationDateTime": "2023-05-23T18:23:45.935Z",
"creatorId": "0649d0bd-53dc-4e1d-a357-76f1d92d447b",
"includeResourceData": null,
"latestSupportedTlsVersion": "v1_2",
"encryptionCertificate": null,
"encryptionCertificateId": null,
"notificationUrlAppId": null