UbiFunctions allow you to run custom server-side code in response to incoming data. Using CoAP, you can trigger any Function in your account by sending a POST request to its dedicated endpoint. This gives your devices a lightweight way to call custom logic such as data processing, validation, forwarding, or integrations with external services.
Endpoint
| Protocol | Endpoint | Port |
|---|---|---|
| CoAP | coap.ubidots.com | 5684 |
Full URL
coap://coap.ubidots.com/iot/functions/<username>/<function_label>Where:
<username>is your Ubidots account username<function_label>is the label of the Function you want to invoke
All requests must be made using the POST method.
Payload Format
The payload you send to a Function is fully defined by your own Function code. UbiFunctions receive the body exactly as you submit it, and your script decides how to interpret it—whether as plain text, JSON, arrays, or structured objects.
In other words, there is no fixed schema. You control the format.
Examples of payloads
Example: generic JSON payload
{
"device": "pump-01",
"value": 42,
"status": "ok"
}{
"trigger": "heartbeat"
}[
{ "value": 10 },
{ "value": 20 }
]UbiFunctions will receive the payload as-is, allowing you to parse and act on it according to the logic you implemented.
Example
If you want to verify your CoAP setup or send test payloads before implementing them in your function, the coap-client utility provides an easy way to make POST requests from the command line:
coap-client \
-m post \
-e '{
"device": "pump-01",
"value": 42,
"status": "ok"}' \
"coap://coap.ubidots.com/iot/functions/my-username/my-function_label/"Notes
- Unlike in other cases, sending data to an UbiFunction doesn't require the inclusion of a token as a query parameter.
- The Function’s response (if any) depends on how you programmed it.
- Keep payloads compact to avoid fragmentation at the UDP/CoAP layer.
- This endpoint does not create devices or variables; it only triggers Function code.
