You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-central/core/howto-manage-device-templates-with-rest-api.md
+10-22Lines changed: 10 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,26 +12,17 @@ services: iot-central
12
12
13
13
# How to use the IoT Central REST API to manage device templates
14
14
15
-
The IoT Central REST API lets you develop client applications that integrate with IoT Central applications. You can use the REST API to manage device templates in your IoT Central application.
15
+
The IoT Central REST API lets you develop client applications that integrate with IoT Central applications. You can use the REST API to manage [device templates](concepts-device-templates.md) in your IoT Central application.
16
16
17
17
Every IoT Central REST API call requires an authorization header. To learn more, see [How to authenticate and authorize IoT Central REST API calls](howto-authorize-rest-api.md).
18
18
19
19
For the reference documentation for the IoT Central REST API, see [Azure IoT Central REST API reference](/rest/api/iotcentral/).
20
20
21
21
## Device templates
22
22
23
-
Any device that's connected to and managed by an IoT Central application is associated with a device template in the application. The device model in the template acts as a contract between the IoT Central application and the devices connected to it. The device template also includes information about how IoT Central displays information about the device in the web UI. For example, a device template can include definitions of dashboards to show device telemetry or to send commands to a device.
23
+
A device template contains a device model, cloud property definitions, customizations, and view definitions. The REST API lets you manage the device model, cloud property definitions, and customizations. Use the UI to create and manage views.
24
24
25
-
The device model section of a device template specifies the capabilities of a device you want to connect to your application. For example, a device template can specify:
26
-
27
-
* The types of telemetry, such as temperature, that your device sends to IoT Central
28
-
* Properties, such as firmware version, that your device will report to IoT Central.
29
-
* Properties, such as target temperature, that IoT Central will set on your device.
30
-
* Commands, such as reboot, that IoT Central will send to your device.
31
-
32
-
The capabilities in a device model are grouped into interfaces. Interfaces enable you to share groups of related capabilities across templates. For example, the common Device Information interface defines device properties such as the manufacturer, model, and software version.
33
-
34
-
Device templates includes _cloud properties_ which specifies any device metadata to store. Cloud properties are never synchronized with devices and only exist in the application. It also includes _customizations_, they can override some of the definitions in the device model. Customizations are useful if you want to refine how the application handles a value, such as changing the display name for a property or the color used to display a telemetry value. However, you cannot add _views_ from the API, it can be added only through the UI.
25
+
The device model section of a device template specifies the capabilities of a device you want to connect to your application. Capabilities include telemetry, properties, and commands. The model is defined using [DTDL](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md).
35
26
36
27
## Device templates REST API
37
28
@@ -45,7 +36,7 @@ The IoT Central REST API lets you:
45
36
46
37
### Add a device template
47
38
48
-
Use the following request to publish a new device template. Default views will be automatically generated for new device templates created this way.
39
+
Use the following request to create and publish a new device template. Default views are automatically generated for device templates created this way.
49
40
50
41
```http
51
42
PUT https://{subdomain}.{baseDomain}/api/deviceTemplates/{deviceTemplateId}?api-version=1.0
@@ -54,7 +45,7 @@ PUT https://{subdomain}.{baseDomain}/api/deviceTemplates/{deviceTemplateId}?api-
54
45
>[!NOTE]
55
46
>Device template IDs follow the [DTDL](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#digital-twin-model-identifier) naming convention, for example: `dtmi:contoso:mythermostattemplate;1`
56
47
57
-
The sample request body looks like the following example:
48
+
The following example shows a request body that adds a device template for a thermostat device. The `capabilityModel` includes temperature telemetry, two properties, and a command. The device template defines the `CustomerName` cloud property and customizes the `targetTemperature` property with `decimalPlaces`, `displayUnit`, `maxValue`, and `minValue`. The value of the device template `@id` must match the `deviceTemplateId` value in the URL. The value of the device template `@id` is not the same as the value of the `capabilityModel``@id` value.
58
49
59
50
```json
60
51
{
@@ -176,7 +167,7 @@ The sample request body looks like the following example:
176
167
}
177
168
```
178
169
179
-
Request body some required fields:
170
+
The request body has some required fields:
180
171
181
172
*`@id`: a unique ID in the form of a simple Uniform Resource Name.
182
173
*`@type`: declares that this object is an interface.
@@ -323,6 +314,9 @@ Use the following request to retrieve details of a device template from your app
323
314
GET https://{subdomain}.{baseDomain}/api/deviceTemplates/{deviceTemplateId}?api-version=1.0
324
315
```
325
316
317
+
>[!NOTE]
318
+
> You can get the `deviceTemplateId` from IoT Central Application UI by hovering the mouse over a device.
319
+
326
320
The response to this request looks like the following example:
Now that you've learned how to manage device templates with the REST API, a suggested next step is to [How to create device templates from IoT Central GUI.](howto-set-up-template.md#create-a-device-template)
Now that you've learned how to manage users and roles with the REST API, a suggested next step is to [How to use the IoT Central REST API to control devices](howto-control-devices-with-rest-api.md).
232
+
Now that you've learned how to manage users and roles with the REST API, a suggested next step is to [How to use the IoT Central REST API to manage device templates](howto-manage-device-templates-with-rest-api.md).
0 commit comments