---
updatedAt: 2026-05-06T22:25:35.000Z
agentTools:
  projectIndex: https://docs.ubidots.com/v1.6/llms.txt
---

# 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

| Protocol | Endpoint         | Port |
| :------- | :--------------- | :--- |
| CoAP     | coap.ubidots.com | 5684 |

### Full URL

```perl Publish
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.

<br />

## 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.

<br />

### Examples of valid payloads

**Single value**

```json Single value
{
  "value": 25
}
```
```json Single Dot object
{
  "value": 25,
  "timestamp": 1712851200000,
  "context": {
    "unit": "C"
  }
}
```
```json Multiple Dots
[
  { "value": 10, "timestamp": 1712851200000 },
  { "value": 20, "timestamp": 1712851260000 }
]
```
```json Position variable
{
  "value": 1,
  "context": {
    "lat": 6.5467,
    "lng": -76.8765
  }
}
```

## Query Parameters

Only one query parameter is required:

| Parameter | Type   | Description                  |
| :-------- | :----- | :--------------------------- |
| `token`   | String | Ubidots 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:

```python Test
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.