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 a new deviceTemplate used to identify attributes and manage a group of devices with similar characteristics.
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) |
DeviceTemplate.Create |
DeviceTemplate.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
DeviceTemplate.Create |
DeviceTemplate.ReadWrite.All |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation:
- Cloud Device Administrator
- IoT Device Administrator
- Users - owners of the device template object
HTTP request
POST /directory/templates/deviceTemplates
Request body
In the request body, supply a JSON representation of the deviceTemplate object.
You can specify the following properties when you create a deviceTemplate.
Property |
Type |
Description |
deviceAuthority |
String |
A tenant-defined name for the party that's responsible for provisioning and managing devices on the Microsoft Entra tenant. For example, Tailwind Traders (the manufacturer) makes security cameras that are installed in customer buildings and managed by Lakeshore Retail (the device authority). This value is provided to the customer by the device authority (manufacturer or reseller). Required. |
manufacturer |
String |
Manufacturer name. Required. |
model |
String |
Model name. Required. |
mutualTlsOauthConfigurationId |
String |
Object ID of the mutualTlsOauthConfiguration. This value isn't required if self-signed certificates are used instead of trusted root certificates. Optional. |
mutualTlsOauthConfigurationTenantId |
String |
ID (tenant ID for device authority) of the tenant that contains the mutualTlsOauthConfiguration. This value isn't required if self-signed certificates are used instead of trusted root certificates. Optional. |
operatingSystem |
String |
Operating system type. Optional. |
[email protected] |
String collection |
List of IDs for owners to add to the device template. Only the following directoryObject types are supported as owners: service principals, users, or applications. Optional. |
Response
If successful, this method returns a 201 Created
response code and a deviceTemplate object in the response body. If a validation failure occurs during the certificate validation steps, the method returns a 400 Bad Request
along with the message, "Unable to validate device certificate".
For more information, see Microsoft Graph error responses and resource types.
Examples
Example 1: Create a new device template
The following example shows how to create a new deviceTemplate.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/directory/templates/deviceTemplates
Content-Type: application/json
Content-length: 106
{
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",
"deviceAuthority": "Lakeshore Retail",
"manufacturer": "Tailwind Traders",
"model": "DeepFreezerModelAB",
"operatingSystem": "WindowsIoT"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DeviceTemplate
{
MutualTlsOauthConfigurationId = "00001111-aaaa-2222-bbbb-3333cccc4444",
MutualTlsOauthConfigurationTenantId = "00001111-aaaa-2222-bbbb-3333cccc4445",
DeviceAuthority = "Lakeshore Retail",
Manufacturer = "Tailwind Traders",
Model = "DeepFreezerModelAB",
OperatingSystem = "WindowsIoT",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.Templates.DeviceTemplates.PostAsync(requestBody);
mgc-beta directory templates device-templates create --body '{\
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",\
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",\
"deviceAuthority": "Lakeshore Retail",\
"manufacturer": "Tailwind Traders",\
"model": "DeepFreezerModelAB",\
"operatingSystem": "WindowsIoT"\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceTemplate()
mutualTlsOauthConfigurationId := "00001111-aaaa-2222-bbbb-3333cccc4444"
requestBody.SetMutualTlsOauthConfigurationId(&mutualTlsOauthConfigurationId)
mutualTlsOauthConfigurationTenantId := "00001111-aaaa-2222-bbbb-3333cccc4445"
requestBody.SetMutualTlsOauthConfigurationTenantId(&mutualTlsOauthConfigurationTenantId)
deviceAuthority := "Lakeshore Retail"
requestBody.SetDeviceAuthority(&deviceAuthority)
manufacturer := "Tailwind Traders"
requestBody.SetManufacturer(&manufacturer)
model := "DeepFreezerModelAB"
requestBody.SetModel(&model)
operatingSystem := "WindowsIoT"
requestBody.SetOperatingSystem(&operatingSystem)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
deviceTemplates, err := graphClient.Directory().Templates().DeviceTemplates().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceTemplate deviceTemplate = new DeviceTemplate();
deviceTemplate.setMutualTlsOauthConfigurationId("00001111-aaaa-2222-bbbb-3333cccc4444");
deviceTemplate.setMutualTlsOauthConfigurationTenantId("00001111-aaaa-2222-bbbb-3333cccc4445");
deviceTemplate.setDeviceAuthority("Lakeshore Retail");
deviceTemplate.setManufacturer("Tailwind Traders");
deviceTemplate.setModel("DeepFreezerModelAB");
deviceTemplate.setOperatingSystem("WindowsIoT");
DeviceTemplate result = graphClient.directory().templates().deviceTemplates().post(deviceTemplate);
const options = {
authProvider,
};
const client = Client.init(options);
const deviceTemplate = {
mutualTlsOauthConfigurationId: '00001111-aaaa-2222-bbbb-3333cccc4444',
mutualTlsOauthConfigurationTenantId: '00001111-aaaa-2222-bbbb-3333cccc4445',
deviceAuthority: 'Lakeshore Retail',
manufacturer: 'Tailwind Traders',
model: 'DeepFreezerModelAB',
operatingSystem: 'WindowsIoT'
};
await client.api('/directory/templates/deviceTemplates')
.version('beta')
.post(deviceTemplate);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DeviceTemplate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceTemplate();
$requestBody->setMutualTlsOauthConfigurationId('00001111-aaaa-2222-bbbb-3333cccc4444');
$requestBody->setMutualTlsOauthConfigurationTenantId('00001111-aaaa-2222-bbbb-3333cccc4445');
$requestBody->setDeviceAuthority('Lakeshore Retail');
$requestBody->setManufacturer('Tailwind Traders');
$requestBody->setModel('DeepFreezerModelAB');
$requestBody->setOperatingSystem('WindowsIoT');
$result = $graphServiceClient->directory()->templates()->deviceTemplates()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
mutualTlsOauthConfigurationId = "00001111-aaaa-2222-bbbb-3333cccc4444"
mutualTlsOauthConfigurationTenantId = "00001111-aaaa-2222-bbbb-3333cccc4445"
deviceAuthority = "Lakeshore Retail"
manufacturer = "Tailwind Traders"
model = "DeepFreezerModelAB"
operatingSystem = "WindowsIoT"
}
New-MgBetaDirectoryTemplateDeviceTemplate -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.device_template import DeviceTemplate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceTemplate(
mutual_tls_oauth_configuration_id = "00001111-aaaa-2222-bbbb-3333cccc4444",
mutual_tls_oauth_configuration_tenant_id = "00001111-aaaa-2222-bbbb-3333cccc4445",
device_authority = "Lakeshore Retail",
manufacturer = "Tailwind Traders",
model = "DeepFreezerModelAB",
operating_system = "WindowsIoT",
)
result = await graph_client.directory.templates.device_templates.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#directory/templates/deviceTemplates/$entity",
"id": "c0ff9329-3596-4ece-8aa9-3dd23a925356",
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",
"deletedDateTime": null,
"deviceAuthority": "Lakeshore Retail",
"manufacturer": "Tailwind Traders",
"model": "DeepFreezerModelAB",
"operatingSystem": "WindowsIoT"
}
Example 2: Create a device template with an owner
The following example shows how to create a new deviceTemplate with an owner.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/directory/templates/deviceTemplates
Content-Type: application/json
Content-length: 106
{
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",
"deviceAuthority": "Lakeshore Retail",
"manufacturer": "Tailwind Traders",
"model": "DeepFreezerModelAB",
"operatingSystem": "WindowsIoT",
"[email protected]": [
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222"
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DeviceTemplate
{
MutualTlsOauthConfigurationId = "00001111-aaaa-2222-bbbb-3333cccc4444",
MutualTlsOauthConfigurationTenantId = "00001111-aaaa-2222-bbbb-3333cccc4445",
DeviceAuthority = "Lakeshore Retail",
Manufacturer = "Tailwind Traders",
Model = "DeepFreezerModelAB",
OperatingSystem = "WindowsIoT",
AdditionalData = new Dictionary<string, object>
{
{
"[email protected]" , new List<string>
{
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222",
}
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.Templates.DeviceTemplates.PostAsync(requestBody);
mgc-beta directory templates device-templates create --body '{\
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",\
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",\
"deviceAuthority": "Lakeshore Retail",\
"manufacturer": "Tailwind Traders",\
"model": "DeepFreezerModelAB",\
"operatingSystem": "WindowsIoT",\
"[email protected]": [\
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222"\
]\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceTemplate()
mutualTlsOauthConfigurationId := "00001111-aaaa-2222-bbbb-3333cccc4444"
requestBody.SetMutualTlsOauthConfigurationId(&mutualTlsOauthConfigurationId)
mutualTlsOauthConfigurationTenantId := "00001111-aaaa-2222-bbbb-3333cccc4445"
requestBody.SetMutualTlsOauthConfigurationTenantId(&mutualTlsOauthConfigurationTenantId)
deviceAuthority := "Lakeshore Retail"
requestBody.SetDeviceAuthority(&deviceAuthority)
manufacturer := "Tailwind Traders"
requestBody.SetManufacturer(&manufacturer)
model := "DeepFreezerModelAB"
requestBody.SetModel(&model)
operatingSystem := "WindowsIoT"
requestBody.SetOperatingSystem(&operatingSystem)
additionalData := map[string]interface{}{
odataBind := []string {
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222",
}
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
deviceTemplates, err := graphClient.Directory().Templates().DeviceTemplates().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceTemplate deviceTemplate = new DeviceTemplate();
deviceTemplate.setMutualTlsOauthConfigurationId("00001111-aaaa-2222-bbbb-3333cccc4444");
deviceTemplate.setMutualTlsOauthConfigurationTenantId("00001111-aaaa-2222-bbbb-3333cccc4445");
deviceTemplate.setDeviceAuthority("Lakeshore Retail");
deviceTemplate.setManufacturer("Tailwind Traders");
deviceTemplate.setModel("DeepFreezerModelAB");
deviceTemplate.setOperatingSystem("WindowsIoT");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<String> ownersOdataBind = new LinkedList<String>();
ownersOdataBind.add("https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222");
additionalData.put("[email protected]", ownersOdataBind);
deviceTemplate.setAdditionalData(additionalData);
DeviceTemplate result = graphClient.directory().templates().deviceTemplates().post(deviceTemplate);
const options = {
authProvider,
};
const client = Client.init(options);
const deviceTemplate = {
mutualTlsOauthConfigurationId: '00001111-aaaa-2222-bbbb-3333cccc4444',
mutualTlsOauthConfigurationTenantId: '00001111-aaaa-2222-bbbb-3333cccc4445',
deviceAuthority: 'Lakeshore Retail',
manufacturer: 'Tailwind Traders',
model: 'DeepFreezerModelAB',
operatingSystem: 'WindowsIoT',
'[email protected]': [
'https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222'
]
};
await client.api('/directory/templates/deviceTemplates')
.version('beta')
.post(deviceTemplate);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DeviceTemplate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceTemplate();
$requestBody->setMutualTlsOauthConfigurationId('00001111-aaaa-2222-bbbb-3333cccc4444');
$requestBody->setMutualTlsOauthConfigurationTenantId('00001111-aaaa-2222-bbbb-3333cccc4445');
$requestBody->setDeviceAuthority('Lakeshore Retail');
$requestBody->setManufacturer('Tailwind Traders');
$requestBody->setModel('DeepFreezerModelAB');
$requestBody->setOperatingSystem('WindowsIoT');
$additionalData = [
'[email protected]' => [
'https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222', ],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->directory()->templates()->deviceTemplates()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
mutualTlsOauthConfigurationId = "00001111-aaaa-2222-bbbb-3333cccc4444"
mutualTlsOauthConfigurationTenantId = "00001111-aaaa-2222-bbbb-3333cccc4445"
deviceAuthority = "Lakeshore Retail"
manufacturer = "Tailwind Traders"
model = "DeepFreezerModelAB"
operatingSystem = "WindowsIoT"
"[email protected]" = @(
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222"
)
}
New-MgBetaDirectoryTemplateDeviceTemplate -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.device_template import DeviceTemplate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceTemplate(
mutual_tls_oauth_configuration_id = "00001111-aaaa-2222-bbbb-3333cccc4444",
mutual_tls_oauth_configuration_tenant_id = "00001111-aaaa-2222-bbbb-3333cccc4445",
device_authority = "Lakeshore Retail",
manufacturer = "Tailwind Traders",
model = "DeepFreezerModelAB",
operating_system = "WindowsIoT",
additional_data = {
"owners@odata_bind" : [
"https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222",
],
}
)
result = await graph_client.directory.templates.device_templates.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#directory/templates/deviceTemplates/$entity",
"id": "c0ff9329-3596-4ece-8aa9-3dd23a925356",
"mutualTlsOauthConfigurationId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"mutualTlsOauthConfigurationTenantId": "00001111-aaaa-2222-bbbb-3333cccc4445",
"deletedDateTime": null,
"deviceAuthority": "Lakeshore Retail",
"manufacturer": "Tailwind Traders",
"model": "DeepFreezerModelAB",
"operatingSystem": "WindowsIoT"
}