This endpoint sends one or more Dots to a variable in a Device.
To send data to a variable in a Device, make a POST request to the following URL:
| HTTP Method | URL |
|---|---|
| POST | https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/<variable_label>/values |
Where <device_label> and <variable_label> are the labels of the Device and Variable, respectively, to which data will be sent.
Headers
The "X-Auth-Token" and "Content-Type" headers are required for your request:
| Header | Value | Required? | Description |
|---|---|---|---|
X-Auth-Token | Token | Yes | Authentication Token for the account |
Content-Type | application/json | Yes | The data type of the request body. |
Body
An object can contain variable labels as keys and Dots as values. The following objects are valid payloads:
{
"value": 10
}{
"value": 10,
"timestamp": 1634311791000,
"context": {
"status": "cold"
}
}[
{
"value": 10,
"timestamp": 1635255765000,
"context": {
"status": "cold"
}
},
{
"value": 25,
"timestamp": 1635255811000,
"context": {
"status": "warm"
}
}
]{
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}For a detailed explanation of a Dot's keys, see How Ubidots works.
timestampandcontextThe
timestampandcontextparameters are optional.
Maximum lengthThe maximum length for the body is 10 KB.
Query Parameters
You may add optional parameters to your request URL:
| Parameter | Type | Description |
|---|---|---|
| timestamp | Integer | Timestamp in POSIX format, in milliseconds. When present, this timestamp will be applied to all Dots in the body unless a local timestamp is sent. |
| token | String | The token to authenticate the request. While sending it as a query parameter is supported, we strongly recommend using the X-Auth-Token header. |
| type | String | Optional Device Type label to apply to the Device if the Device doesn't exist yet. Learn more. |
| status | Boolean | Optional. When set to true, an additional _status object appears in the response. It contains the IDs of the device and variables, as well as a new field indicating whether they were just created. Example:\ |
Examples
Send a single value to a variable:
Update a variable and let Ubidots apply a timestamp equal to the reception time.
$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/<variable_label>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{"value": 10}'{
"context":{},
"created_at":1635256409897,
"timestamp":1635256409897,
"value":10.0
}{
"code":400001,
"message":"The payload sent is not a valid json document."
}{
"code":401001,
"message":"Authentication credentials were not provided."
}Send multiple values to a variable:
Update a variable with multiple Dots. Each Dot must have its own timestamp.
$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/<variable_label>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '[
{"value": 10, "timestamp": 1635255765000},
{"value": 20, "timestamp": 1635255811000}
]'{
"temperature":[{"status_code":201}],
"humidity":[{"status_code":201}]
}{
"code":400001,
"message":"The payload sent is not a valid json document."
}{
"code":401001,
"message":"Authentication credentials were not provided."
}Send location data:
This updates a position variable so that the Device displays its location.
curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/position/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{"value": 1, "context": {"lat": 6.5467, "lng": -76.8765}}'{
"context": {"lat": 6.5467, "lng": -76.8765},
"created_at": 1635256962165,
"timestamp": 1635256962165,
"value":1.0
}{
"code": 400001,
"message": "The payload sent is not a valid json document."
}{
"code": 401001,
"message": "Authentication credentials were not provided."
}
