Use this endpoint to send data to one or more variables of a Device

To send data to one or more variables of a Device please make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/

Where <device_label> is a string with the label of the Device to which data will be sent to.

Headers

The "X-Auth-Token" and "Content-Type" headers are required to your request:

HeaderValueRequired?Description
X-Auth-TokenTokenYes[Authentication Token] (/reference/authentication) of account.
Content-Typeapplication/jsonYesThe type of data of the body.

Body

An object containing keys as variable labels and Dots as values. The following are all valid payloads:

{
  "temperature": 10
}
{
  "temperature": 10,
  "humidity": 90,
  "pressure": 78
}
{
  "temperature": {
    "value": 10,
    "timestamp": 1634311791000,
    "context": {
      "status": "cold"
    }
  }
}
{
  "temperature": {
    "value": 10,
    "timestamp": 1634311791000,
    "context": {
      "status": "cold"
    }
  },
  "humidity": {
    "value": 90,
    "timestamp": 1634311791000,
    "context": {
      "status": "High humidity"
    }
  },
  "pressure": {
    "value": 78,
    "timestamp": 1634311791000,
    "context": {
      "status": "Normal"
    }
  }
}
{
  "position": {
    "value": 1, 
    "context": {
      "lat": "6.5423", 
      "lng": "-70.5783"
    }
  }
}

For a detailed explanation of a Dots' keys, please see here.

📘

timestamp and context

The timestamp and context parameters are optional.

🚧

Maximum length

The maximum character length for the body is 10kb

Query Parameters

You may add optional parameters to the URL of your request:

ParameterTypeDescription
timestampIntegerTimestamp in milliseconds POSIX format. When present, this timestamp will be applied to all Dots in the body unless a local timestamp is sent.
tokenStringThe token to authenticate the request.
While sending it as a query parameter is supported, we strongly recommend using the X-Auth-Token header
typeStringOptional Device Type label to be applied to the Device if the Device doesn't exist yet. Learn more

Sending location data

You may use the context key to send location data. Ubidots will automatically recognize location data when using these variable labels:

  • position
  • location
  • gps

There are 3 ways to send location data:

{
  "position": {
    "value": 1, 
    "context": {
      "lat": "6.5423", 
      "lng": "-70.5783"
    }
  }
}
// Since the "value" of a dot is mandatory, this option will set the variable value to "1".

{
  "position": {
      "lat": "6.5423", 
      "lng": "-70.5783"
    }
}
// Since the "value" of a dot is mandatory, this option will set the variable value to  "1".

{
  "position": {
      "latitude": "6.5423", 
      "longitude": "-70.5783"
    }
}

📘

Location modes

The location of a device can be determined by a variable or a fixed property. Please see here to learn more about Device Location modes.

Examples

Send a value to a single 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>/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{"temperature": 10}'
{
  "temperature":[{"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 value to multiple variables:
Update two variables 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>/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{"temperature": 10, "humidty": 90}'
{
  "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 Dot to multiple variables:
Update multiple variables, including context and timestamp:

$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{
  "temperature": {
    "value": 10,
    "timestamp": 1634311791000,
    "context": {
      "status": "cold"
    }
  },
  "humidity": {
    "value": 90,
    "timestamp": 1634311791000,
    "context": {
      "status": "High humidity"
    }
  },
  "pressure": {
    "value": 78,
    "timestamp": 1634311791000,
    "context": {
      "status": "Normal"
    }
  }
}'
{
  "temperature":[{"status_code":201}],
  "humidity":[{"status_code":201}],
  "pressure":[{"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/devices/<device_label>/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{"position":{"lat":6.2442, "lng":-75.5812}}'
{
  "position":[{"status_code":201}],
}
{
  "code":400001,
  "message":"The payload sent is not a valid json document."
}
{
  "code":401001,
  "message":"Authentication credentials were not provided."
}

Send data with global timestamp:
Update multiples variables with a global timestamp sent as a query parameter. Variables with an individual timestamp will override the global timestamp:

$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/?timestamp=1634311791000' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{
  "temperature": {
    "value": 10,
    "context": {
      "status": "cold"
    }
  },
  "humidity": {
    "value": 90,
    "context": {
      "status": "High humidity"
    }
  },
  "pressure": {
    "value": 78,
    "timestamp": 1634336087000,
    "context": {
      "status": "Normal"
    }
  }
}'

Send historical data to a Device (data logger):
Send multiple Dots per variable. Each Dot requires its own timestamp

$ curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{
  "temperature": [
    {"value": 10,"timestamp": 1634336087000},
    {"value": 11,"timestamp": 1634336088765}
  ],
  "humidity": [
    {"value": 90,"timestamp": 1634336087000},
    {"value": 95,"timestamp": 1634336088765}
  ],
  "pressure": [
    {"value": 78,"timestamp": 1634336087000},
    {"value": 82,"timestamp": 1634336088765}
  ]
}'

📘

Sending data in bulk

To send historical data (i.e. from data loggers) without having to specify an individual timestamp per variable, check out the bulk data endpoint.