Microsoft Graph API Calendar Example

Victoria Jul 07, 2026

The Microsoft Graph API is a powerful tool for integrating Microsoft cloud services into your applications. One of its most useful features is the ability to manage and interact with calendars. Whether you're building a custom calendar app or looking to automate scheduling tasks, understanding how to use the Microsoft Graph API for calendars is essential. Let's dive into an example that demonstrates how to create, update, and view events using the Microsoft Graph API.

How to Use Microsoft Graph API in SPFx Web Parts
How to Use Microsoft Graph API in SPFx Web Parts

Before we begin, ensure you have registered an application in Azure Active Directory and obtained the necessary permissions and access tokens. You'll also need to install the Microsoft Graph SDK for your preferred programming language. In this example, we'll use JavaScript with the @microsoft/microsoft-graph-client library.

Using Microsoft Graph API inside Microsoft Flow in O365
Using Microsoft Graph API inside Microsoft Flow in O365

Setting Up the Microsoft Graph Client

The first step is to initialize the Microsoft Graph client with your access token. You can obtain an access token by following the OAuth 2.0 authorization code flow with PKCE. Once you have the token, you can initialize the client like this:

an image of a calendar on the computer screen with time and date options for each month
an image of a calendar on the computer screen with time and date options for each month

const client = new Client({authProvider: async (scopes) => {return accessToken;}});

Creating a New Event

Microsoft Calendar - Chris Salmon
Microsoft Calendar - Chris Salmon

To create a new event, you'll need to make a POST request to the /me/events endpoint. Here's an example of creating an event with a subject, start and end times, and a location:

await client.api('/me/events').post({subject: 'Meeting with Team',
    startDateTime: '2022-03-15T09:30:34',
    endDateTime: '2022-03-15T10:00:34',
    location: {displayName: 'Office',
        address: {streetAddress: '123 Main St',
            city: 'Seattle',
            state: 'WA',
            country: 'USA'}}}});

Updating an Existing Event

How to Create Year and School Calendar with Dynamic Date Markers » The Spreadsheet Page
How to Create Year and School Calendar with Dynamic Date Markers » The Spreadsheet Page

To update an event, you'll need to make a PATCH request to the event's unique identifier. Let's say you want to change the location of the previously created event:

await client.api('/me/events/eventId').patch({location: {displayName: 'Home Office',
    address: {streetAddress: '456 Oak St',
        city: 'Seattle',
        state: 'WA',
        country: 'USA'}}}}});

Viewing and Managing Events

Best Calendar Ideas
Best Calendar Ideas

To retrieve a list of your events, make a GET request to the /me/events endpoint. You can also filter events by specifying query parameters:

const events = await client.api('/me/events').get({queryParameters: {startDateTime: '2022-03-01',
    endDateTime: '2022-03-31'}});

a purple and white calendar on a tablet screen
a purple and white calendar on a tablet screen
Interactive Excel Calendar with Heatmap – Free Download
Interactive Excel Calendar with Heatmap – Free Download
Support Tip: Getting Started with Microsoft Graph API | Microsoft Community Hub
Support Tip: Getting Started with Microsoft Graph API | Microsoft Community Hub
a desktop computer with a calendar on the screen and a plant in front of it
a desktop computer with a calendar on the screen and a plant in front of it
Best Digital Calendar Apps for Productivity in 2025
Best Digital Calendar Apps for Productivity in 2025
an image of a calendar on the computer screen
an image of a calendar on the computer screen
Announcing Microsoft Lists - Your smart information tracking app in Microsoft 365
Announcing Microsoft Lists - Your smart information tracking app in Microsoft 365
a calendar with different times on it and numbers for each month, including the date
a calendar with different times on it and numbers for each month, including the date
Using Office 365 Calendar and Groups for Increased Efficiency
Using Office 365 Calendar and Groups for Increased Efficiency
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
Availability Calendar Template
Availability Calendar Template
Microsoft Outlook Calendar vs Google Calendar: Complete Comparison | Calendar Printables Free Templates
Microsoft Outlook Calendar vs Google Calendar: Complete Comparison | Calendar Printables Free Templates
Apple Calendar Hacks That Will Change Your Daily Life
Apple Calendar Hacks That Will Change Your Daily Life
FREE Calendar Templates
FREE Calendar Templates
Master Your Schedule with Microsoft 360’s Calendar
Master Your Schedule with Microsoft 360’s Calendar
40+ Microsoft Calendar Templates - Free Word, Excel Documents
40+ Microsoft Calendar Templates - Free Word, Excel Documents
UI design Calendar, Planner, Events, Schedule, CRM
UI design Calendar, Planner, Events, Schedule, CRM
The 7 Best Calendar Apps in the Microsoft Store
The 7 Best Calendar Apps in the Microsoft Store
How to Create a Dynamic Monthly Calendar in Google Sheets - Template Provided
How to Create a Dynamic Monthly Calendar in Google Sheets - Template Provided
Outlook
Outlook

Deleting an Event

To delete an event, make a DELETE request to the event's unique identifier:

await client.api('/me/events/eventId').delete();

With these examples, you now have a solid foundation for using the Microsoft Graph API to manage calendars. Whether you're creating, updating, or deleting events, the Microsoft Graph API provides a powerful and flexible way to integrate calendar functionality into your applications. Happy coding!