Telemetry
Publish telemetry by sending a CoAP POST request. See Getting Connected for credential types and connection details.
Endpoints
Section titled “Endpoints”| Credential type | URL |
|---|---|
| Access Token | coap(s)://coap.thingsboard.cloud:5683/api/v1/$ACCESS_TOKEN/telemetry |
| X.509 Certificate | coaps://coap.thingsboard.cloud/api/v1/telemetry |
Payload Formats
Section titled “Payload Formats”Simple Key-Value
Section titled “Simple Key-Value”A flat JSON object of key-value pairs. ThingsBoard assigns the server receive time as the timestamp.
{"temperature": 42, "humidity": 73}Access Token:
coap-client -v 6 -m POST -t "application/json" -e '{"temperature":42,"humidity":73}' "coap://coap.thingsboard.cloud:5683/api/v1/$ACCESS_TOKEN/telemetry"X.509 Certificate:
coap-client-openssl -v 6 -c cert.pem -j key.pem -m POST -t "application/json" -e '{"temperature":42,"humidity":73}' "coaps://coap.thingsboard.cloud/api/v1/telemetry"With Client-Side Timestamp
Section titled “With Client-Side Timestamp”Include ts (Unix milliseconds) when the device has a reliable clock and you want the exact measurement time stored instead of the server receive time.
{"ts": 1451649600512, "values": {"temperature": 42, "humidity": 73}}Access Token:
coap-client -v 6 -m POST -t "application/json" -e '{"ts":1451649600512,"values":{"temperature":42,"humidity":73}}' "coap://coap.thingsboard.cloud:5683/api/v1/$ACCESS_TOKEN/telemetry"1451649600512 is a Unix timestamp in milliseconds — corresponds to Fri, 01 Jan 2016 12:00:00.512 GMT.
Array of Objects with Client-Side Timestamps
Section titled “Array of Objects with Client-Side Timestamps”Send a batch of readings in a single request, each with its own timestamp. Use this to flush buffered measurements captured while offline.
[ {"ts": 1451649600512, "values": {"temperature": 42, "humidity": 73}}, {"ts": 1451649601000, "values": {"temperature": 43, "humidity": 72}}]Access Token:
coap-client -v 6 -m POST -t "application/json" -e '[{"ts":1451649600512,"values":{"temperature":42,"humidity":73}},{"ts":1451649601000,"values":{"temperature":43,"humidity":72}}]' "coap://coap.thingsboard.cloud:5683/api/v1/$ACCESS_TOKEN/telemetry"