Sending data to a variable

Send one or more values to a specific variable on a device.
All CoAP requests must use the POST method and include your Ubidots token as a query parameter.

Endpoint

ProtocolEndpointPort
CoAPcoap.ubidots.com5684

Full URL

coap://coap.ubidots.com/iot/devices/<device_label>/<variable_label>/values?token=<TOKEN>

Where:

  • <device_label> is the label of the device receiving the data.
  • <variable_label> is the label of the variable you want to update.
  • <TOKEN> is your Ubidots account token.

Payload Format

The payload must be encoded as JSON. Ubidots accepts the same value formats as the REST API, including simple values, full Dot objects, arrays of Dots, and position updates.


Examples of valid payloads

Single value

{
  "value": 25
}
{
  "value": 25,
  "timestamp": 1712851200000,
  "context": {
    "unit": "C"
  }
}
[
  { "value": 10, "timestamp": 1712851200000 },
  { "value": 20, "timestamp": 1712851260000 }
]
{
  "value": 1,
  "context": {
    "lat": 6.5467,
    "lng": -76.8765
  }
}

Query Parameters

Only one query parameter is required:

ParameterTypeDescription
tokenStringUbidots authentication token

The timestamp and context must be included in the payload itself, per Dot, not as query parameters.

Example

To verify your CoAP setup or send test payloads before implementing them, use the coap-client utility to make POST requests from the command line:

coap-client \
  -m post \
  -e '{"value": 25}' \
"coap://coap.ubidots.com/iot/devices/my-device-label/my-variable_label/values?token=BBFF-your_token_here"

Notes

  • CoAP messages must be sent as POST requests.
  • Ubidots uses the reception time as the timestamp if none is provided.
  • The maximum payload size depends on your device’s CoAP stack and network MTU, but we recommend keeping payloads compact.