Namespace: microsoft.graph
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Use this API to create a new calendar in a calendar group for a user.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
✅ |
✅ |
✅ |
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
| Permission type |
Permissions (from least to most privileged) |
| Delegated (work or school account) |
Calendars.ReadWrite |
| Delegated (personal Microsoft account) |
Calendars.ReadWrite |
| Application |
Calendars.ReadWrite |
HTTP request
A user's default calendarGroup.
POST /me/calendars
POST /users/{id | userPrincipalName}/calendars
Any calendarGroup of a user.
POST /me/calendarGroups/{id}/calendars
POST /users/{id | userPrincipalName}/calendarGroups/{id}/calendars
Request body
In the request body, supply a JSON representation of calendar object.
Response
If successful, this method returns 201 Created response code and calendar object in the response body.
Example
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/calendarGroups/AAMkADYAAAR9NR5AAA=/calendars
Content-type: application/json
{
"name": "Marketing calendar"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Calendar
{
Name = "Marketing calendar",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.CalendarGroups["{calendarGroup-id}"].Calendars.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCalendar()
name := "Marketing calendar"
requestBody.SetName(&name)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
calendars, err := graphClient.Me().CalendarGroups().ByCalendarGroupId("calendarGroup-id").Calendars().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Calendar calendar = new Calendar();
calendar.setName("Marketing calendar");
Calendar result = graphClient.me().calendarGroups().byCalendarGroupId("{calendarGroup-id}").calendars().post(calendar);
const options = {
authProvider,
};
const client = Client.init(options);
const calendar = {
name: 'Marketing calendar'
};
await client.api('/me/calendarGroups/AAMkADYAAAR9NR5AAA=/calendars')
.version('beta')
.post(calendar);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Calendar;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Calendar();
$requestBody->setName('Marketing calendar');
$result = $graphServiceClient->me()->calendarGroups()->byCalendarGroupId('calendarGroup-id')->calendars()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
name = "Marketing calendar"
}
# A UPN can also be used as -UserId.
New-MgBetaUserCalendarGroupCalendar -UserId $userId -CalendarGroupId $calendarGroupId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.calendar import Calendar
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Calendar(
name = "Marketing calendar",
)
result = await graph_client.me.calendar_groups.by_calendar_group_id('calendarGroup-id').calendars.post(request_body)
In the request body, supply a JSON representation of calendar object.
Response
The following example shows the response. Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('68ca8ec0-11f8-456b-a785-70d9936650d5')/calendarGroups('AAMkADYAAAR9NR5AAA%3D')/calendars/$entity",
"id": "AAMkADYCQM0GfRAAAcrRD-AAA=",
"name": "Marketing calendar",
"color": "auto",
"changeKey": "4xTfgHLeDkOqYVAkDNBn0QAAHKl46A==",
"canShare": true,
"canViewPrivateItems": true,
"canEdit": true,
"owner": {
"name": "Adele Vance",
"address": "adelev@contoso.com"
}
}