Microsoft Graph API: Create Calendar Event Example

Victoria Jul 07, 2026

Microsoft Graph API empowers developers to access Microsoft Cloud service resources, including Outlook, Calendar, and Teams. Creating a calendar event via the Microsoft Graph API is a common task, enabling automation and integration with other applications. Let's delve into an example of creating a calendar event using the Microsoft Graph API.

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

Before we dive into the example, ensure you have registered an application in Azure Active Directory (Azure AD) and have the necessary permissions. You'll need the client ID, tenant ID, and client secret to authenticate and obtain an access token.

a purple and white calendar on a tablet screen
a purple and white calendar on a tablet screen

Preparing the Access Token

The first step is to acquire an access token with the required permissions. You'll need the `Calendars.ReadWrite` or `Calendars.ReadWrite.All` permission, depending on whether you're creating events for yourself or others.

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

Use the client ID, tenant ID, and client secret to obtain an access token using the OAuth 2.0 client credentials flow. Here's a simple example using cURL:

```bash curl -X POST -d "client_id=YOUR_CLIENT_ID&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials" https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token ```

Setting up the API Endpoint and Headers

Interactive Excel Calendar with Heatmap – Free Download
Interactive Excel Calendar with Heatmap – Free Download

With the access token, you can now set up the API endpoint and headers for creating a calendar event. The API endpoint for creating an event is `https://graph.microsoft.com/v1.0/me/events` for creating an event in your primary calendar, or `https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/events` for creating an event in a specific user's calendar.

Include the access token in the `Authorization` header with the `Bearer` scheme. Also, set the `Content-Type` header to `application/json` to indicate that you'll be sending JSON data in the request body.

Creating a Calendar Event

an image of a calendar with different times and dates for each month, including the date
an image of a calendar with different times and dates for each month, including the date

Now that we have the access token and API endpoint, we can create a calendar event. Here's an example of creating a new event using cURL and JSON data:

```bash curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"subject":"Meet for lunch","body":{"contentType":"Text","content":"The new cafeteria is open."},"startDateTime":"2023-02-14T12:00:34.2446042-07:00","endDateTime":"2023-02-14T13:00:34.2446042-07:00"}' https://graph.microsoft.com/v1.0/me/events ```

Understanding the JSON Body

The JSON body of the request contains the event details. Here's a breakdown of the properties used in the example:

Free Content Calendar Template | ConversionMinded
Free Content Calendar Template | ConversionMinded
  • subject: The title of the event.
  • body: The content of the event. In this case, it's a simple text message.
  • startDateTime and endDateTime: The start and end times of the event, in ISO 8601 format.

You can include additional properties, such as location, attendees, and recurrence patterns, to create more complex events.

an event calendar with a magnifying glass next to it
an event calendar with a magnifying glass next to it
Interactive calendar with visualization data periods in Excel
Interactive calendar with visualization data periods in Excel
Best Digital Calendar Apps for Productivity in 2025
Best Digital Calendar Apps for Productivity in 2025
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
Free Calendrier mensuel des événements Modèle en Google Sheets and Microsoft Excel | thegoodocs.com
Free Calendrier mensuel des événements Modèle en Google Sheets and Microsoft Excel | thegoodocs.com
Using Curtains in Microsoft Project to Show What Work is Being Done Within a Sprint
Using Curtains in Microsoft Project to Show What Work is Being Done Within a Sprint
Side by Side Calendar with events
Side by Side Calendar with events
Best Calendar Ideas
Best Calendar Ideas
4 Best Free Event Planning Software for Mac
4 Best Free Event Planning Software for Mac
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
Create a Calendar in Microsoft Excel or Insert a Reference Calendar
a poster with the dates and times for an event in black and white, on a light blue background
a poster with the dates and times for an event in black and white, on a light blue background
UI design Calendar, Planner, Events, Schedule, CRM
UI design Calendar, Planner, Events, Schedule, CRM
5 Best Microsoft Teams Shared Calendar App
5 Best Microsoft Teams Shared Calendar App
an image of a calendar on the computer screen
an image of a calendar on the computer screen
Free Online Calendar Planner & Daily Planner | Toggl 2.0
Free Online Calendar Planner & Daily Planner | Toggl 2.0
The only customizable calendar for business - Teamup Home
The only customizable calendar for business - Teamup Home
Template event calendar fall
Template event calendar fall
a calendar is shown with different colors and numbers
a calendar is shown with different colors and numbers
Monatsplaner Excel: Effiziente Planung leicht gemacht – Jetzt herunterladen!
Monatsplaner Excel: Effiziente Planung leicht gemacht – Jetzt herunterladen!
Event Calendar Excel Template | Calender in Excel Template
Event Calendar Excel Template | Calender in Excel Template

After sending the request, the API will respond with the newly created event's details, including its unique identifier (`id`). You can now use this ID to update or delete the event as needed.

In conclusion, creating a calendar event using the Microsoft Graph API is a straightforward process that enables you to automate and integrate calendar management into your applications. By following the example provided, you can create calendar events programmatically, streamlining your workflow and enhancing user experiences.