This endpoint creates a new Device Type.
Request
To create a new Device Type please make a POST request to the following URL:
HTTP Method | URL |
---|---|
POST | https://industrial.api.ubidots.com/api/v2.0/device_types/ |
Query Parameters
Parameter | Type | Use | Description |
---|---|---|---|
token | String | Authentication | Authentication Token can optionally be sent as a query parameter. |
Body Parameters
Parameter | Type | Required? | Default Value | Description |
---|---|---|---|---|
label | String | No | N/A (required) | API label of Device Type |
name | String | Yes | slug(label ) | Name of Device Group |
description | String | No | "" | Description of Device Group |
deviceColor | String | No | "" | Color of Device Type |
deviceIcon | String | No | "" | Color of Device Type |
variableColor | String | No | "" | Color of Variables related to Device Type |
syntheticVariableColor | String | No | "" | Color of Synthetic Variables related to Device Type |
variables | Object Array | No | [] | Variables related to Device Type |
properties | Object Array | No | [] | Properties of Device Type |
tasks | Object Array | No | [] | Tasks of Device Type |
fromDevice | String | No | "" | The id or label of the original Device to copy directly all the variables and properties in the new Device type. Label should use the prefix ~ |
Header
Parameter | Type | Description |
---|---|---|
X-Auth-Token | String | Authentication Token of account |
Content-Type | String (application/json) | Content type of body |
curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/device_types/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"name": "device-name",
"label": "device-label",
"description": "Brief description for the device",
"deviceColor": "#3BA9F5",
"deviceIcon": "pencil",
"variableColor": "#FFAE58",
"syntheticVariableColor": "#",
"variables": [
{
"properties": {
"isLocationVariable": false,
"hidden": false,
"_color": "#FFAE58",
"_icon": "cloud-upload"
},
"label": "var0",
"name": "var0",
"description": "",
"tags": null,
"type": 0,
"unit": ""
}
],
"properties": [],
"tasks": [
{
"id": "acbdee1d8472323763ff1b",
"type": "dashboard",
"name": "{{device.name}} Dashboard"
}
]
}'
{
"url": "https://industrial.api.ubidots.com/api/v2.0/device_types/5e1f7e5789f9bd7c4e7f1e2c",
"id": "5e1f7e5789f9bd7c4e7f1e2c",
"name": "device-name",
"label": "device-label",
"description": "Brief description for the device",
"deviceColor": "#3BA9F5",
"deviceIcon": "pencil",
"variableColor": "#FFAE58",
"syntheticVariableColor": "#",
"variables": [
{
"properties": {
"isLocationVariable": false,
"hidden": false,
"_color": "#FFAE58",
"_icon": "cloud-upload"
},
"label": "var0",
"name": "var0",
"description": "",
"tags": null,
"type": 0,
"unit": ""
}
],
"properties": [],
"tasks": [
{
"id": "acbdee1d8472323763ff1b",
"type": "dashboard",
"name": "{{device.name}} Dashboard"
}
],
"createdAt": "2020-01-15T21:04:23.602975Z"
}
{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}
{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}
Using fromDevice parameter
Variables hierarchy
If you use the 'fromDevice' parameter and manually create variables in the request, the original device variables won't carry over to the new Device Type. Only variables associated in "variables" key will be created.
Original device | Variables | Properties |
---|---|---|
Name: demo Id: 64a5f0fe48928307ca715349 | API Label: battery, position, temp. | Device serial, Route statu |
curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/device_types/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"name": "device-name",
"label": "device-label",
"description": "Brief description for the device",
"deviceColor": "#3BA9F5",
"deviceIcon": "pencil",
"variableColor": "#FFAE58",
"syntheticVariableColor": "#",
"tasks": [
{
"id": "acbdee1d8472323763ff1b",
"type": "dashboard",
"name": "{{device.name}} Dashboard"
}
],
"fromDevice": "64a5f0fe48928307ca715349"
}'
{
"url": "https://industrial.api.ubidots.com/api/v2.0/device_types/5e1f7e5789f9bd7c4e7f1e2c",
"id": "5e1f7e5789f9bd7c4e7f1e2c",
"name": "device-name",
"label": "device-label",
"description": "Brief description for the device",
"deviceColor": "#3BA9F5",
"deviceIcon": "pencil",
"variableColor": "#FFAE58",
"syntheticVariableColor": "#",
"variables": [
{
"label": "temp",
"properties": {},
"type": 0,
"name": "Temp",
"description": "",
"tags": [],
"derived_expr": "",
"unit": "°C"
},
{
"label": "position",
"properties": {},
"type": 0,
"name": "Position",
"description": "",
"tags": [],
"derived_expr": "",
"unit": null
},
{
"label": "battery",
"properties": {},
"type": 0,
"name": "Battery",
"description": "",
"tags": [],
"derived_expr": "",
"unit": "%"
}
],
"properties": [
{
"key": "p1",
"text": "Device serial",
"description": "",
"type": "text",
"value": ""
},
{
"key": "p2",
"text": "Route status",
"description": "",
"type": "text",
"value": ""
}
],
"tags": [],
"tasks": [
{
"id": "acbdee1d8472323763ff1b",
"type": "dashboard",
"name": "{{device.name}} Dashboard"
}
],
"createdAt": "2024-02-22T22:06:30.338626Z"
}
{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}
{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}
Response
Returns an Device Type object of the Device Type created.