Create openShift

Namespace: microsoft.graph

Create an instance of an openShift 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 Group.Read.All, Group.ReadWrite.All
Delegated (personal Microsoft account) Not supported. Not supported.
Application Schedule.ReadWrite.All Not available.

Note: This API supports admin permissions. Users with admin roles can access groups that they are not a member of.

HTTP request

POST /teams/{id}/schedule/openShifts

Request headers

Name Description
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 the modified openShift object.

The following table lists the properties that you can use when you create an openShift object.

Property Type Description
draftOpenShift openShiftItem Draft changes in the openShift are only visible to managers until they're shared. Either draftOpenShift or sharedOpenShift should be null.
isStagedForDeletion Boolean The openShift is marked for deletion, a process that is finalized when the schedule is shared. Optional.
schedulingGroupId String The ID of the schedulingGroup that contains the openShift.
sharedOpenShift openShiftItem The shared version of this openShift that is viewable by both employees and managers. Either draftOpenShift or sharedOpenShift should be null.

Response

If successful, this method returns a 200 OK response code and the created openShift object in the response body.

Examples

Request

The following example shows a request.

POST https://graph.microsoft.com/v1.0/teams/788b75d2-a911-48c0-a5e2-dc98480457e3/schedule/openShifts
Authorization: Bearer {token}
Content-type: application/json

{
  "schedulingGroupId": "TAG_4ab7d329-1f7e-4eaf-ba93-63f1ff3f3c4a",
  "sharedOpenShift": {
    "displayName": "Dayshift",
    "startDateTime": "2024-11-04T20:00:00Z",
    "endDateTime": "2024-11-04T21:00:00Z",
    "theme": "blue",
    "notes": "InventoryManagement",
    "openSlotCount": 1,
    "activities": []
  },
  "draftTimeOff": null,
  "isStagedForDeletion": false
}

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

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('48ba9e52-8d25-41c7-bbe7-5ee6346eec0d')/schedule/openShifts/$entity",
    "@odata.etag": "\"4002def0-0000-0c00-0000-672ea2ff0000\"",
    "id": "OPNSHFT_6f5e1d7c-3ebe-449f-abfc-d677d26f0b5c",
    "createdDateTime": "2024-11-08T23:47:11.605Z",
    "lastModifiedDateTime": "2024-11-08T23:47:11.605Z",
    "schedulingGroupId": "TAG_4ab7d329-1f7e-4eaf-ba93-63f1ff3f3c4a",
    "draftOpenShift": null,
    "lastModifiedBy": {
        "application": null,
        "device": null,
        "user": {
            "id": "366c0b19-49b1-41b5-a03f-9f3887bd0ed8",
            "displayName": "John Doe",
            "userIdentityType": "aadUser",
            "tenantId": null
        }
    },
    "sharedOpenShift": {
        "displayName": null,
        "startDateTime": "2024-11-04T20:00:00Z",
        "endDateTime": "2024-11-04T21:00:00Z",
        "theme": "blue",
        "notes": null,
        "openSlotCount": 1,
        "activities": []
    },
    "isStagedForDeletion": false
}