Namespace: microsoft.graph
Create or replace a schedule object.
The schedule creation process conforms to the One API guideline for resource based long running operations (RELO).
When clients use the PUT method, if the schedule is provisioned, the operation replaces the schedule; otherwise, the operation starts the schedule provisioning process in the background.
During schedule provisioning, clients can use the GET method to get the schedule and look at the provisionStatus
property for the current state of the provisioning. If the provisioning failed, clients can get additional information from the provisionStatusCode
property.
Clients can also inspect the configuration of the schedule.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
❌ |
❌ |
❌ |
Permissions
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
PUT /teams/{teamId}/schedule
Header |
Value |
Authorization |
Bearer {token}. Required. Learn more about authentication and authorization. |
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, supply a JSON representation of a schedule object.
Response
If successful, this method returns a 200 OK
response code and a schedule object in the response body.
Example
Request
The following example shows a request.
PUT https://graph.microsoft.com/v1.0/teams/{teamId}/schedule
Content-type: application/json
{
"enabled": true,
"timeZone": "America/Chicago"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Schedule
{
Enabled = true,
TimeZone = "America/Chicago",
};
// 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.PutAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchedule()
enabled := true
requestBody.SetEnabled(&enabled)
timeZone := "America/Chicago"
requestBody.SetTimeZone(&timeZone)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schedule, err := graphClient.Teams().ByTeamId("team-id").Schedule().Put(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Schedule schedule = new Schedule();
schedule.setEnabled(true);
schedule.setTimeZone("America/Chicago");
Schedule result = graphClient.teams().byTeamId("{team-id}").schedule().put(schedule);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const schedule = {
enabled: true,
timeZone: 'America/Chicago'
};
await client.api('/teams/{teamId}/schedule')
.put(schedule);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Schedule;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Schedule();
$requestBody->setEnabled(true);
$requestBody->setTimeZone('America/Chicago');
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->put($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Teams
$params = @{
enabled = $true
timeZone = "America/Chicago"
}
Set-MgTeamSchedule -TeamId $teamId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schedule import Schedule
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Schedule(
enabled = True,
time_zone = "America/Chicago",
)
result = await graph_client.teams.by_team_id('team-id').schedule.put(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "833fc4df-c88b-4398-992f-d8afcfe41df2",
"enabled": true,
"timeZone": "America/Chicago",
"provisionStatus": "Completed",
"provisionStatusCode": null,
"timeClockEnabled": true,
"openShiftsEnabled": true,
"swapShiftsRequestsEnabled": true,
"offerShiftRequestsEnabled": true,
"timeOffRequestsEnabled": true
}
Related content
Microsoft Graph service-specific throttling limits