Namespace: microsoft.graph
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant.
Create a new deviceComplianceActionItem 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
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
DeviceManagementConfiguration.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Application |
DeviceManagementConfiguration.ReadWrite.All |
HTTP Request
POST /deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/scheduledActionsForRule/{deviceComplianceScheduledActionForRuleId}/scheduledActionConfigurations
Request body
In the request body, supply a JSON representation for the deviceComplianceActionItem object.
The following table shows the properties that are required when you create the deviceComplianceActionItem.
Property |
Type |
Description |
id |
String |
Key of the entity. |
gracePeriodHours |
Int32 |
Number of hours to wait till the action will be enforced. Valid values 0 to 8760 |
actionType |
deviceComplianceActionType |
What action to take. Possible values are: noAction , notification , block , retire , wipe , removeResourceAccessProfiles , pushNotification . |
notificationTemplateId |
String |
What notification Message template to use |
notificationMessageCCList |
String collection |
A list of group IDs to speicify who to CC this notification message to. |
Response
If successful, this method returns a 201 Created
response code and a deviceComplianceActionItem object in the response body.
Example
Request
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/scheduledActionsForRule/{deviceComplianceScheduledActionForRuleId}/scheduledActionConfigurations
Content-type: application/json
Content-length: 271
{
"@odata.type": "#microsoft.graph.deviceComplianceActionItem",
"gracePeriodHours": 0,
"actionType": "notification",
"notificationTemplateId": "Notification Template Id value",
"notificationMessageCCList": [
"Notification Message CCList value"
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceComplianceActionItem
{
OdataType = "#microsoft.graph.deviceComplianceActionItem",
GracePeriodHours = 0,
ActionType = DeviceComplianceActionType.Notification,
NotificationTemplateId = "Notification Template Id value",
NotificationMessageCCList = new List<string>
{
"Notification Message CCList value",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.DeviceCompliancePolicies["{deviceCompliancePolicy-id}"].ScheduledActionsForRule["{deviceComplianceScheduledActionForRule-id}"].ScheduledActionConfigurations.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc device-management device-compliance-policies scheduled-actions-for-rule scheduled-action-configurations create --device-compliance-policy-id {deviceCompliancePolicy-id} --device-compliance-scheduled-action-for-rule-id {deviceComplianceScheduledActionForRule-id} --body '{\
"@odata.type": "#microsoft.graph.deviceComplianceActionItem",\
"gracePeriodHours": 0,\
"actionType": "notification",\
"notificationTemplateId": "Notification Template Id value",\
"notificationMessageCCList": [\
"Notification Message CCList value"\
]\
}\
'
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.NewDeviceComplianceActionItem()
gracePeriodHours := int32(0)
requestBody.SetGracePeriodHours(&gracePeriodHours)
actionType := graphmodels.NOTIFICATION_DEVICECOMPLIANCEACTIONTYPE
requestBody.SetActionType(&actionType)
notificationTemplateId := "Notification Template Id value"
requestBody.SetNotificationTemplateId(¬ificationTemplateId)
notificationMessageCCList := []string {
"Notification Message CCList value",
}
requestBody.SetNotificationMessageCCList(notificationMessageCCList)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
scheduledActionConfigurations, err := graphClient.DeviceManagement().DeviceCompliancePolicies().ByDeviceCompliancePolicyId("deviceCompliancePolicy-id").ScheduledActionsForRule().ByDeviceComplianceScheduledActionForRuleId("deviceComplianceScheduledActionForRule-id").ScheduledActionConfigurations().Post(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);
DeviceComplianceActionItem deviceComplianceActionItem = new DeviceComplianceActionItem();
deviceComplianceActionItem.setOdataType("#microsoft.graph.deviceComplianceActionItem");
deviceComplianceActionItem.setGracePeriodHours(0);
deviceComplianceActionItem.setActionType(DeviceComplianceActionType.Notification);
deviceComplianceActionItem.setNotificationTemplateId("Notification Template Id value");
LinkedList<String> notificationMessageCCList = new LinkedList<String>();
notificationMessageCCList.add("Notification Message CCList value");
deviceComplianceActionItem.setNotificationMessageCCList(notificationMessageCCList);
DeviceComplianceActionItem result = graphClient.deviceManagement().deviceCompliancePolicies().byDeviceCompliancePolicyId("{deviceCompliancePolicy-id}").scheduledActionsForRule().byDeviceComplianceScheduledActionForRuleId("{deviceComplianceScheduledActionForRule-id}").scheduledActionConfigurations().post(deviceComplianceActionItem);
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 deviceComplianceActionItem = {
'@odata.type': '#microsoft.graph.deviceComplianceActionItem',
gracePeriodHours: 0,
actionType: 'notification',
notificationTemplateId: 'Notification Template Id value',
notificationMessageCCList: [
'Notification Message CCList value'
]
};
await client.api('/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/scheduledActionsForRule/{deviceComplianceScheduledActionForRuleId}/scheduledActionConfigurations')
.post(deviceComplianceActionItem);
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\DeviceComplianceActionItem;
use Microsoft\Graph\Generated\Models\DeviceComplianceActionType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceComplianceActionItem();
$requestBody->setOdataType('#microsoft.graph.deviceComplianceActionItem');
$requestBody->setGracePeriodHours(0);
$requestBody->setActionType(new DeviceComplianceActionType('notification'));
$requestBody->setNotificationTemplateId('Notification Template Id value');
$requestBody->setNotificationMessageCCList(['Notification Message CCList value', ]);
$result = $graphServiceClient->deviceManagement()->deviceCompliancePolicies()->byDeviceCompliancePolicyId('deviceCompliancePolicy-id')->scheduledActionsForRule()->byDeviceComplianceScheduledActionForRuleId('deviceComplianceScheduledActionForRule-id')->scheduledActionConfigurations()->post($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.DeviceManagement
$params = @{
"@odata.type" = "#microsoft.graph.deviceComplianceActionItem"
gracePeriodHours = 0
actionType = "notification"
notificationTemplateId = "Notification Template Id value"
notificationMessageCCList = @(
"Notification Message CCList value"
)
}
New-MgDeviceManagementDeviceCompliancePolicyScheduledActionForRuleScheduledActionConfiguration -DeviceCompliancePolicyId $deviceCompliancePolicyId -DeviceComplianceScheduledActionForRuleId $deviceComplianceScheduledActionForRuleId -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.device_compliance_action_item import DeviceComplianceActionItem
from msgraph.generated.models.device_compliance_action_type import DeviceComplianceActionType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceComplianceActionItem(
odata_type = "#microsoft.graph.deviceComplianceActionItem",
grace_period_hours = 0,
action_type = DeviceComplianceActionType.Notification,
notification_template_id = "Notification Template Id value",
notification_message_c_c_list = [
"Notification Message CCList value",
],
)
result = await graph_client.device_management.device_compliance_policies.by_device_compliance_policy_id('deviceCompliancePolicy-id').scheduled_actions_for_rule.by_device_compliance_scheduled_action_for_rule_id('deviceComplianceScheduledActionForRule-id').scheduled_action_configurations.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 320
{
"@odata.type": "#microsoft.graph.deviceComplianceActionItem",
"id": "e01a1893-1893-e01a-9318-1ae093181ae0",
"gracePeriodHours": 0,
"actionType": "notification",
"notificationTemplateId": "Notification Template Id value",
"notificationMessageCCList": [
"Notification Message CCList value"
]
}