Create deviceTemplate

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 headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

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.
owners@odata.bind 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"
}

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",
  "owners@odata.bind": [
    "https://graph.microsoft.com/beta/users/aaaaaaaa-bbbb-cccc-1111-222222222222"
  ]
}

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"
}