Skip to content

MSGraphWebhooks ​

Create and manage Microsoft Graph change notification subscriptions to receive webhook events for resources like mail, calendar, and OneDrive.

Credentials ​

Uses the Entra ID app registration (client_id, tenant_id, client_secret). Grant Graph permissions for the resources you subscribe to (mail, calendar, OneDrive, etc.).

Usage ​

python
from elsai_cloud.microsoft_webhooks import MSGraphWebhooks

ms_graph = MSGraphWebhooks(
    client_id="your_client_id",
    tenant_id="your_tenant_id",
    client_secret="your_client_secret",
)

Create a subscription:

python
ms_graph.create_subscription(
    change_type="change_type",
    notification_url="https://webhook.example.com/notifications",
    resource="me/mailFolders('Inbox')/messages",
    expiration_date_time="2016-11-20T18:23:45.9356913Z",
    client_state="custom_state_123",
)

Get a subscription:

python
subscription = ms_graph.get_subscription(subscription_id="your_subscription_id")

List all subscriptions:

python
subs_list = ms_graph.list_subscriptions()

Update a subscription:

python
ms_graph.update_subscription(
    subscription_id="subscription_id",
    notification_url="https://webhook.example.com/notifications",
    expiration_date_time="2016-11-20T18:23:45.9356913Z",
)

Delete a subscription:

python
ms_graph.delete_subscription(subscription_id="subscription_id")

See also ​

Copyright © 2026 elsai foundry.