Submit Sensor Data
Route
POST /api/public/v0/devices/:deviceId/data
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceId | string | Depends | The unique identifier (DevEUI) of the device. |
Note: This endpoint accommodates an exception to the standard parameter specification for API users who are unable to specify the deviceId in the URL on a per-device basis. In this case, the deviceId can be specified in the body of the request using the dev_eui field (see below). The server will always attempt to use the dev_eui field specified in the body unless it is not present, in which case it will fall back to the one specified in the URL. In all cases however, for proper routing, there must be some value specified for :deviceId in the URL. This can be any string as long as dev_eui is present in the body.
If /api/public/v0/devices/data is used, the server will interpret it as a different endpoint entirely (which does not accept POST requests) and respond with an error.
Body
There are two types of payloads that can be sent to this endpoint, depending on whether you wish to send a single reading or several readings at once.
In both payload types, any of the sensor data types can be omitted or null, but there must be at least one valid, non-null value in the payload or the request will be rejected.
Single Payload
The single payload includes a single data reading for temperature, humidity, rain, ullage, RSSI, and SNR. It also contains device information.
Example:
{ "end_device_ids": { "dev_eui": "A1B2C3D4E5F6" }, "uplink_message": { "decoded_payload": { "temperature": 24.2, "humidity": 58, "rain": 0, "ullage": 98, "rssi": -65, "snr": 9.0 } }}Batch Payload
The batch payload contains multiple readings, where each reading includes data such as temperature, humidity, rain, ullage, signal strength (RSSI), and signal-to-noise ratio (SNR). The payload also contains the device information and sensor reading interval for the batch.
Understanding the interval Field and Timestamp Assignment
The interval field denotes the time interval, in milliseconds, between each consecutive reading in the data array. It is assumed that the readings in the data array are evenly spaced in time, based on this interval. When processing batch payloads, the system uses this field to assign timestamps to each reading as follows:
- The most recent reading (last in the
dataarray) is assigned the current timestamp (when the request was received). - For each preceding reading, the timestamp is calculated by subtracting multiples of the
intervalfrom the current timestamp.
For example, if the current time is 12:00:00 PM, the interval is 300,000 milliseconds (5 minutes), and there are 3 readings in the data array:
- The 3rd (last) reading is timestamped 12:00:00 PM
- The 2nd reading is timestamped 11:55:00 AM
- The 1st reading is timestamped 11:50:00 AM
Example:
{ "end_device_ids": { "dev_eui": "A1B2C3D4E5F6" }, "uplink_message": { "decoded_payload": { "interval": 60000, // readings are one minute apart "data": [ { "temperature": 22.5, "humidity": 60, "rain": 0, "ullage": 100, "rssi": -70, "snr": 7.5 }, { "temperature": 23.1, "humidity": 62, "rain": 0, "ullage": 98, "rssi": -68, "snr": 8.1 } ] } }}Response Codes
| Code | Description |
|---|---|
| 500 | Internal server error |
| 400 | Invalid parameters or format |
| 404 | Device not found |
| 200 | Successful submission |