Share a schedule time range with schedule members.
Make the collections of shift, openshift and timeOff items in the specified time range of the schedule viewable by the specified team members, including employees and managers.
Each shift, openshift and timeOff instance in a schedule supports a draft version and a shared version of the item. The draft version is viewable by only managers, and the shared version is viewable by employees and managers. For each shift, openshift and timeOff instance in the specified time range, the share action updates the shared version from the draft version, so that in addition to managers, employees can also view the most current information about the item. The notifyTeam parameter further specifies which employees can view the item.
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type
Least privileged permissions
Higher privileged permissions
Delegated (work or school account)
Schedule.ReadWrite.All
Group.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Schedule.ReadWrite.All
Not available.
HTTP request
POST /teams/{teamId}/schedule/share
Request headers
Header
Value
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
MS-APP-ACTS-AS
A user ID (GUID). Required only if the authorization token is an application token; otherwise, optional.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
notifyTeam
Boolean
Indicates whether the entire team should get a visible notification of this action, or only employees that have a shift assigned to them that was shared. Required.
startDateTime
DateTimeOffset
The start time to share shifts on the schedule from. Required.
endDateTime
DateTimeOffset
The end time to share shifts on the schedule until.
Response
If successful, this method returns a 200 OK response code. It doesn't return anything in the response body.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Teams.Item.Schedule.Share;
var requestBody = new SharePostRequestBody
{
NotifyTeam = true,
StartDateTime = DateTimeOffset.Parse("2018-10-08T00:00:00.000Z"),
EndDateTime = DateTimeOffset.Parse("2018-10-15T00:00:00.000Z"),
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teams["{team-id}"].Schedule.Share.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc teams schedule share post --team-id {team-id} --body '{\
"notifyTeam": true,\
"startDateTime": "2018-10-08T00:00:00.000Z",\
"endDateTime": "2018-10-15T00:00:00.000Z"\
}\
'
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SharePostRequestBody();
$requestBody->setNotifyTeam(true);
$requestBody->setStartDateTime(new \DateTime('2018-10-08T00:00:00.000Z'));
$requestBody->setEndDateTime(new \DateTime('2018-10-15T00:00:00.000Z'));
$graphServiceClient->teams()->byTeamId('team-id')->schedule()->share()->post($requestBody)->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(credentials, scopes)
request_body = SharePostRequestBody(
notify_team = True,
start_date_time = "2018-10-08T00:00:00.000Z",
end_date_time = "2018-10-15T00:00:00.000Z",
)
await graph_client.teams.by_team_id('team-id').schedule.share.post(request_body)