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.
Create instance of a timeoffrequest object.
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 |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Schedule.ReadWrite.All |
Not available. |
HTTP request
POST /teams/{teamId}/schedule/timeOffRequests
Optional query parameters
This method doesn't support OData query parameters to customize the response.
Name |
Description |
Authorization |
Bearer {token}. Required. Learn more about authentication and authorization. |
Content-type |
application/json. Required. |
MS-APP-ACTS-AS (deprecated) |
A user ID (GUID). Required only if the authorization token is an application token; otherwise, optional. The MS-APP-ACTS-AS header is deprecated and no longer required with application tokens. |
Request body
In the request body, provide a JSON representation of a new timeoffrequest object.
Response
If successful, this method returns a 200 OK response code and the created timeoffrequest object in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/teams/{teamId}/schedule/timeOffRequests
{
"senderMessage": "Need a break",
"timeOffReasonId": "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3",
"senderUserId": "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
"startDateTime": "2025-05-26T07:00:00Z",
"endDateTime": "2025-05-27T07:00:00Z"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TimeOffRequest
{
SenderMessage = "Need a break",
TimeOffReasonId = "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3",
SenderUserId = "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
StartDateTime = DateTimeOffset.Parse("2025-05-26T07:00:00Z"),
EndDateTime = DateTimeOffset.Parse("2025-05-27T07:00:00Z"),
};
// 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.TimeOffRequests.PostAsync(requestBody);
mgc-beta teams schedule time-off-requests create --team-id {team-id}
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTimeOffRequest()
senderMessage := "Need a break"
requestBody.SetSenderMessage(&senderMessage)
timeOffReasonId := "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3"
requestBody.SetTimeOffReasonId(&timeOffReasonId)
senderUserId := "3f2504e0-4f89-11d3-9a0c-0305e82c3301"
requestBody.SetSenderUserId(&senderUserId)
startDateTime , err := time.Parse(time.RFC3339, "2025-05-26T07:00:00Z")
requestBody.SetStartDateTime(&startDateTime)
endDateTime , err := time.Parse(time.RFC3339, "2025-05-27T07:00:00Z")
requestBody.SetEndDateTime(&endDateTime)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
timeOffRequests, err := graphClient.Teams().ByTeamId("team-id").Schedule().TimeOffRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TimeOffRequest timeOffRequest = new TimeOffRequest();
timeOffRequest.setSenderMessage("Need a break");
timeOffRequest.setTimeOffReasonId("TOR_08c42f26-9b83-492c-bf52-f3609eb083e3");
timeOffRequest.setSenderUserId("3f2504e0-4f89-11d3-9a0c-0305e82c3301");
OffsetDateTime startDateTime = OffsetDateTime.parse("2025-05-26T07:00:00Z");
timeOffRequest.setStartDateTime(startDateTime);
OffsetDateTime endDateTime = OffsetDateTime.parse("2025-05-27T07:00:00Z");
timeOffRequest.setEndDateTime(endDateTime);
TimeOffRequest result = graphClient.teams().byTeamId("{team-id}").schedule().timeOffRequests().post(timeOffRequest);
const options = {
authProvider,
};
const client = Client.init(options);
const timeOffRequest = {
senderMessage: 'Need a break',
timeOffReasonId: 'TOR_08c42f26-9b83-492c-bf52-f3609eb083e3',
senderUserId: '3f2504e0-4f89-11d3-9a0c-0305e82c3301',
startDateTime: '2025-05-26T07:00:00Z',
endDateTime: '2025-05-27T07:00:00Z'
};
await client.api('/teams/{teamId}/schedule/timeOffRequests')
.version('beta')
.post(timeOffRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TimeOffRequest;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TimeOffRequest();
$requestBody->setSenderMessage('Need a break');
$requestBody->setTimeOffReasonId('TOR_08c42f26-9b83-492c-bf52-f3609eb083e3');
$requestBody->setSenderUserId('3f2504e0-4f89-11d3-9a0c-0305e82c3301');
$requestBody->setStartDateTime(new \DateTime('2025-05-26T07:00:00Z'));
$requestBody->setEndDateTime(new \DateTime('2025-05-27T07:00:00Z'));
$result = $graphServiceClient->teams()->byTeamId('team-id')->schedule()->timeOffRequests()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
senderMessage = "Need a break"
timeOffReasonId = "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3"
senderUserId = "3f2504e0-4f89-11d3-9a0c-0305e82c3301"
startDateTime = [System.DateTime]::Parse("2025-05-26T07:00:00Z")
endDateTime = [System.DateTime]::Parse("2025-05-27T07:00:00Z")
}
New-MgBetaTeamScheduleTimeOffRequest -TeamId $teamId -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.time_off_request import TimeOffRequest
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TimeOffRequest(
sender_message = "Need a break",
time_off_reason_id = "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3",
sender_user_id = "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
start_date_time = "2025-05-26T07:00:00Z",
end_date_time = "2025-05-27T07:00:00Z",
)
result = await graph_client.teams.by_team_id('team-id').schedule.time_off_requests.post(request_body)
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": "SREQ_54f7ae3c-dc28-4773-8135-811dd8db2121",
"createdDateTime": "2025-05-22T20:50:26.796Z",
"lastModifiedDateTime": "2025-05-22T20:50:26.796Z",
"assignedTo": "manager",
"state": "pending",
"senderDateTime": "2025-05-22T20:50:26.796Z",
"senderMessage": "Need a break",
"senderUserId": "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
"managerActionDateTime": null,
"managerActionMessage": null,
"managerUserId": null,
"startDateTime": "2025-05-26T07:00:00Z",
"endDateTime": "2025-05-27T07:00:00Z",
"timeOffReasonId": "TOR_08c42f26-9b83-492c-bf52-f3609eb083e3",
"lastModifiedBy": {
"user": {
"id": "3f2504e0-4f89-11d3-9a0c-0305e82c3301",
"displayName": "Ava Mitchell",
"userIdentityType": "aadUser",
}
}
}