Use this endpoint to send data to one variable
To send data to one variable please make a POST request to the following URL:
| HTTP Method | URL |
|---|---|
| POST | https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/values |
Where <variable_id> is a string with the id of the Variable to which data will be sent to.
Headers
The "X-Auth-Token" and "Content-Type" headers are required to your request:
| Header | Value | Required? | Description |
|---|---|---|---|
X-Auth-Token | Token | Yes | Authentication Token of account. |
Content-Type | application/json | Yes | The type of data of the body. |
Body
An object containing either a single value or Dot, or multiple Dots. The following are all valid payloads:
{
"value": 10
}{
"value": 10,
"timestamp": 1635369947000,
"context": {}
}// All values 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 a Dots' keys, please see here.
timestampandcontextThe
timestampandcontextparameters are optional.
Maximum lengthThe maximum character length for the body is 10kb
Query Parameters
You may add optional parameters to the URL of your request:
Parameter | Type | Description |
|---|---|---|
token | String | The token to authenticate the request. |
Examples
Send a 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/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 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 a multiple Dots to a variable:
Update a variable with multiple Dots, including their timestamp:
$ 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."
}