Create Device Type

This endpoint creates a new Device Type.

Request

To create a new Device Type please make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v2.0/device_types/

Query Parameters

ParameterTypeUseDescription
tokenStringAuthenticationAuthentication Token can optionally be sent as a query parameter.

Body Parameters

ParameterTypeRequired?Default ValueDescription
labelStringNoN/A (required)API label of Device Type
nameStringYesslug(label)Name of Device Group
descriptionStringNo""Description of Device Group
deviceColorStringNo""Color of Device Type
deviceIconStringNo""Color of Device Type
variableColorStringNo""Color of Variables related to Device Type
syntheticVariableColorStringNo""Color of Synthetic Variables related to Device Type
variablesObject ArrayNo[]Variables related to Device Type
propertiesObject ArrayNo[]Properties of Device Type
tasksObject ArrayNo[]Tasks of Device Type
fromDeviceStringNo""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

ParameterTypeDescription
X-Auth-TokenStringAuthentication Token of account
Content-TypeString (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 deviceVariablesProperties
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.