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.
Draft changes in the shift. Draft changes are only visible to managers. The changes are visible to employees when they're shared, which copies the changes from the draftShift to the sharedShift property. Eiher draShift or sharedShift should be null.
isStagedForDeletion
Boolean
The shift is marked for deletion, a process that is finalized when the schedule is shared. Optional.
schedulingGroupId
String
ID of the scheduling group the shift is part of. Required.
The shared version of this shift that is viewable by both employees and managers. Updates to the sharedShift property send notifications to users in the Teams client. Eiher draShift or sharedShift should be null.
userId
String
ID of the user assigned to the shift. Required.
Response
If successful, this method returns a 201 Created response code and a shift object in the response body.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Shift
{
UserId = "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
DraftShift = new ShiftItem
{
DisplayName = null,
StartDateTime = DateTimeOffset.Parse("2024-10-08T15:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2024-10-09T00:00:00Z"),
Theme = ScheduleEntityTheme.Blue,
Notes = null,
Activities = new List<ShiftActivity>
{
},
},
SharedShift = null,
AdditionalData = new Dictionary<string, object>
{
{
"isStagedForDeletion" , false
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Schedule.Shifts.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Shift shift = new Shift();
shift.setUserId("5ca83ce7-291d-43b7-bf53-af79eef4bc1d");
ShiftItem draftShift = new ShiftItem();
draftShift.setDisplayName(null);
OffsetDateTime startDateTime = OffsetDateTime.parse("2024-10-08T15:00:00Z");
draftShift.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2024-10-09T00:00:00Z");
draftShift.setEndDateTime(endDateTime);
draftShift.setTheme(ScheduleEntityTheme.Blue);
draftShift.setNotes(null);
LinkedList<ShiftActivity> activities = new LinkedList<ShiftActivity>();
draftShift.setActivities(activities);
shift.setDraftShift(draftShift);
shift.setSharedShift(null);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("isStagedForDeletion", false);
shift.setAdditionalData(additionalData);
Shift result = graphClient.teams().byTeamId("{team-id}").schedule().shifts().post(shift);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.shift import Shift
from msgraph.generated.models.shift_item import ShiftItem
from msgraph.generated.models.schedule_entity_theme import ScheduleEntityTheme
from msgraph.generated.models.shift_activity import ShiftActivity
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Shift(
user_id = "5ca83ce7-291d-43b7-bf53-af79eef4bc1d",
draft_shift = ShiftItem(
display_name = None,
start_date_time = "2024-10-08T15:00:00Z",
end_date_time = "2024-10-09T00:00:00Z",
theme = ScheduleEntityTheme.Blue,
notes = None,
activities = [
],
),
shared_shift = None,
additional_data = {
"is_staged_for_deletion" : False,
}
)
result = await graph_client.teams.by_team_id('team-id').schedule.shifts.post(request_body)