Use this endpoint to send data to one variable
To send data to one variable, make a POST request to the following URL:
| HTTP Method | URL |
|---|---|
| POST | https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values |
<variable_id> is a string with the ID of the variable to which data will be sent.
Headers
The "X-Auth-Token" and "Content-Type" headers are required in 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 body. |
Body
An object containing either a single value, a single Dot, or multiple Dots. The following are all valid payloads:
{
"value": 10
}{
"value": 10,
"timestamp": 1635369947000,
"context": {}
}// Each value in the array must have its own timestamp
[
{
"value": 10,
"timestamp": 1635369947000
},
{
"value": 11,
"timestamp": 1635369948000
},
{
"value": 12,
"timestamp": 1635369949000
}
]{
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}For a detailed explanation of Dot keys, see How Ubidots Works.
timestampandcontextThe
timestampandcontextparameters are optional.
Maximum lengthThe maximum character length for the body is 10 KB.
Query Parameters
You may add optional parameters to your request URL:
| Parameter | Type | Description |
|---|---|---|
| token | String | The token to authenticate the request. Although sending it as a query parameter is supported, we strongly recommend using the X-Auth-Token header. |
Examples
Send a value to a variable:
Update a variable and let Ubidots apply a timestamp equal to the time of receipt:
$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{"value": 27}'{
"value": 27,
"timestamp": 1635371040531,
"context": {},
"created_at": 1635371040531
}{
"code":400001,
"message":"The payload sent is not a valid json document."
}{
"code":401001,
"message":"Authentication credentials were not provided."
}Send a Dot to a variable:
Update a variable with a timestamp and context:
$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"value":27,
"timestamp":1635369947000,
"context":{
"status":"warm"
}
}'{
"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 multiple Dots to a variable:
Update a variable with multiple Dots, including their timestamps:
$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '[
{
"value": 10,
"timestamp": 1635369947000
},
{
"value": 11,
"timestamp": 1635369948000
},
{
"value": 12,
"timestamp": 1635369949000
}
]'[
{
"status_code": 201
},
{
"status_code": 201
},
{
"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:
Update a position variable so that the device displays its location:
curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}'{
"value": 1,
"timestamp": 1635428407266,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
},
"created_at": 1635428407266
}{
"code":400001,
"message":"The payload sent is not a valid json document."
}{
"code":401001,
"message":"Authentication credentials were not provided."
}
