This endpoint creates a new Variable.
Request
To create a new Variable please make a POST request to the following URL:
| HTTP Method | URL |
|---|---|
| POST | https://industrial.api.ubidots.com/api/v2.0/variables/ |
To create a new Variable of a Device please make a POST request to the following URL:
| HTTP Method | URL |
|---|---|
| POST | https://industrial.api.ubidots.com/api/v2.0/devices/<device_key>/variables/ |
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 | Yes | N/A (required) | API label of Variable |
| name | String | No | Same as label | Name of Variable |
| description | String | No | "" | Description of Variable |
| device | <device_key> | Yes | N/A (required) | Key of Device (id or label) |
| tags | String Array | No | [] | Variable tags |
| properties | Object | No | {} | Variable properties. Allowed attributes: _icon, _color, minimum_value, maximum_value, isLocationVariable, _position, _scale, _offset |
| type | String | No | raw | Variable type. Allowed values raw (default) and synthetic |
| unit | String | No | "" | Variable unit |
| syntheticExpression | String | No | "" | Synthetic Expression of Variable |
Properties Attributes Explained
_icon: Icon of Variable (FontAwesome)
_color: HEX, RGB and RGBA
minimum_value: Lowest value allowed (Dots posted with a value below theminimum_valuewill not be saved)
maximum_value: Highest value allowed (Dots posted with a value above themaximum_valuewill not be saved)
isLocationVariable: Boolean value if the Variable should be taken as location Variable (device location mode: specified)
_scale: All incoming values will be multiplied with this value
_offset: All incoming values will be summed with this value
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/variables/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"label": "second-variable",
"name": "Second Variable",
"description": "my second variable",
"device": "~first-device",
"tags": ["blue", "yellow"],
"properties": {},
"icon": "pencil",
"unit": "meters"
}'{
"createdAt": "2019-12-18T14:38:38.354415Z",
"syntheticExpression": "",
"description": "my second variable",
"device": {
"id": "6e309da44fc8455a9cceb5aa",
"label": "first-device",
"name": "First Device",
"url": "https://industrial.api.ubidots.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa"
},
"icon": "pencil",
"id": "5dfa39ee1a9ca53020c69391",
"label": "var0",
"lastActivity": null,
"lastValue": {},
"name": "var0",
"properties": {},
"tags": ["blue", "yellow"],
"type": "raw",
"unit": "meters",
"url": "https://industrial.api.ubidots.com/api/v2.0/variables/5dfa39ee1a9ca53020c69391",
"valuesUrl": "https://industrial.api.ubidots.com/api/v1.6/variables/5dfa39ee1a9ca53020c69391/values"
}{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}Response
Returns a Variable object of the Variable created.
