Skip to content

Send data over HTTP ​

A device sends its readings with one HTTP request: POST /ingest with a JSON body. This page describes what the endpoint accepts and returns, so you can call it from any language or board.

You need the device_uid and the secret of a device. Connect your first device shows how to create one.

The request ​

http
POST /ingest HTTP/1.1
Host: localhost:8090
Content-Type: application/json
Authorization: Basic ZGV2XzM4MzNjZTFlOnNlY19mZDFjLi4u

{"temperature": 21.7, "humidity": 45}
  • The path is /ingest, at the root of the instance. It is not under /api.
  • The body is one JSON object. An array is refused.
  • The device's own uid and secret are the only credentials. An API key or the dashboard password is not used here.

Authentication ​

Send the device_uid and the secret in one of two ways. If a request has both, the header wins.

WayHow
HTTP BasicAuthorization: Basic base64(uid:secret). This keeps the secret out of the body. Use it when you can.
In the body"uid" and "secret" fields in the JSON object. Use it where you cannot set headers.

The bundled stack serves plain HTTP, so the secret travels unencrypted on your network. For HTTPS, put a reverse proxy in front of Sensora. See Security.

Reserved fields ​

FieldTypeMeaning
uidstringThe device_uid, when you authenticate in the body
secretstringThe device secret, when you authenticate in the body
recorded_atstringOptional time of the reading. See Timestamps

Every other field is the payload.

What becomes a metric ​

A metric is a named series of numbers, such as temperature. What Sensora stores from a payload depends on whether the device has a template.

Device without a template. Sensora looks at the top level of the JSON object only.

ValueStored
A number, for example 21.7Yes, under the name of the field
true or falseYes, as 1 or 0
A string, also one that holds a number, for example "21.7"No
null, an object or an arrayNo

Device with a template. Sensora reads only the fields that the template lists, each from its source path. A path can point into nested objects, for example state.pressure_kpa. Numbers, booleans and strings that hold a number are stored, with the unit from the template. If some template fields are missing from a payload, the others are still stored.

Two field names have an extra effect:

  • battery_v: a device whose latest battery_v is below 3.3 shows as Low battery.
  • rssi: a top-level number named rssi is also saved as the device's signal strength.

Timestamps ​

Without recorded_at, a reading gets the time at which the server received it. The device needs no clock.

To set the time yourself, add recorded_at as an ISO 8601 string:

json
{"temperature": 19.5, "recorded_at": "2026-11-19T10:00:00Z"}
  • One request has one time. All values in the body get the same timestamp.
  • There is no batch format. To upload stored readings, send one request per timestamp and stay inside the rate limit.
  • recorded_at also becomes the device's last-seen time. If you send an old timestamp, the device can show as Offline until a reading with a current time arrives.

Responses ​

StatusBodyMeaning
200{"ok":true,"device_uid":"dev_3833ce1e","stored":2}Accepted. stored is the number of values saved.
400{"error":"invalid_json"}The body is not JSON.
400{"error":"missing uid or secret"}No credentials in the header or the body, or the body is not a JSON object.
401{"error":"unauthorized"}No device has this uid, or the secret is wrong. Both cases give the same answer.
413An HTML error pageThe body is larger than 10 MB.
422{"error":"decode_failed","detail":"…"}The request is valid, but the body has nothing to store.
429{"error":"rate_limited"}Too many requests. See Rate limits.
500{"error":"internal_error"}The server failed. A recorded_at that is not a valid date gives this answer, and nothing is stored.

The detail of a 422 says what was missing:

  • no numeric fields in payload: the device has no template and the body has no top-level number or boolean.
  • no decodable fields; missing temperature, humidity: the device has a template and none of its fields is in the body.

A 422 also writes an event that you can read on the Logs tab of the device.

A 200 with "stored": 0 means that no rule saved the reading. The built-in Store telemetry rule does this, so check on the Rules page that it is turned on.

The response never carries data for the device. Sensora cannot send commands or settings back in the answer.

Rate limits ​

LimitApplies toDefault
Per deviceRequests with valid credentialsA burst of 60 requests, refilled at 1 request per second
Per client IP addressRequests answered with 400 or 401A burst of 100 requests, refilled at 50 per second

A request over the limit gets 429 and is not stored. Wait at least one second before you try again. To change the defaults, see Configuration.

Examples ​

Replace the address, the uid and the secret with your own. From a device, use the network address of your instance, not localhost.

bash
curl -X POST http://localhost:8090/ingest \
  -u 'dev_3833ce1e:sec_fd1c8e78b4da9670089a8de97f5731f49218dc35daab5557' \
  -H 'Content-Type: application/json' \
  -d '{"temperature":21.7,"humidity":45}'
bash
curl -X POST http://localhost:8090/ingest \
  -H 'Content-Type: application/json' \
  -d '{"uid":"dev_3833ce1e","secret":"sec_fd1c8e78b4da9670089a8de97f5731f49218dc35daab5557","temperature":21.7,"humidity":45}'
python
import requests

r = requests.post(
    "http://localhost:8090/ingest",
    auth=("dev_3833ce1e", "sec_fd1c8e78b4da9670089a8de97f5731f49218dc35daab5557"),
    json={"temperature": 21.7, "humidity": 45},
    timeout=10,
)
print(r.status_code, r.json())

The Python example needs the requests package (pip install requests).

ESP32 with the Arduino framework ​

This sketch joins Wi-Fi and sends two values every 60 seconds. It uses only the WiFi and HTTPClient libraries that come with the ESP32 Arduino core.

cpp
#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>

const char* WIFI_SSID = "my-network";
const char* WIFI_PASSWORD = "my-password";
const char* INGEST_URL = "http://192.168.1.20:8090/ingest";
const char* DEVICE_UID = "dev_xxxxxxxx";
const char* DEVICE_SECRET = "sec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

void setup() {
  Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void loop() {
  float temperature = 21.7;  // replace with your sensor reading
  float humidity = 45.0;

  String body = "{\"temperature\":" + String(temperature, 1) + ",\"humidity\":" + String(humidity, 1) + "}";

  HTTPClient http;
  http.begin(INGEST_URL);
  http.setAuthorization(DEVICE_UID, DEVICE_SECRET);
  http.addHeader("Content-Type", "application/json");
  int status = http.POST(body);
  Serial.printf("POST /ingest: %d %s\n", status, http.getString().c_str());
  http.end();

  delay(60000);
}

The sketch does not reconnect when Wi-Fi drops and does not retry a failed request. The Arduino library does both for you.

Announce what the device is ​

POST /ingest/announce is optional. A device can call it once after it starts, before its first reading, to tell Sensora what it is and what it sends. Sensora then creates a template for it and a starter dashboard. Firmware built with the Arduino library calls it for you.

It uses the same credentials as /ingest and the same rate limit.

bash
curl -X POST http://localhost:8090/ingest/announce \
  -u 'dev_3833ce1e:sec_fd1c8e78b4da9670089a8de97f5731f49218dc35daab5557' \
  -H 'Content-Type: application/json' \
  -d '{
    "firmware": {"name": "room-sensor", "version": "1.0.0", "chip": "ESP32"},
    "interval_s": 60,
    "sensors": [{"model": "SHT41", "bus": "i2c", "address": "0x44"}],
    "properties": [
      {"id": "temperature", "unit": "°C", "type": "number", "sensor": "SHT41"},
      {"id": "humidity", "unit": "%", "type": "number", "sensor": "SHT41"}
    ]
  }'
json
{"ok":true,"template":"room-sensor-sht41-c224","dashboard_id":"b6825b75-3fbf-4b30-9bd0-2456410163ba"}
FieldTypeMeaning
firmwareobjectname (up to 64 characters), version (32), library (32) and chip (32). All optional.
interval_sintegerSeconds between readings, 1 to 86400. Optional.
sensorsarray, up to 16Each has a model, and optional bus and address.
propertiesarray, up to 48Each has an id (1 to 32 letters, digits, _, . or -), and optional unit, type (number, boolean or string, default number) and sensor.

What Sensora does with an announcement:

  • It creates a template from the properties and gives it to the device. The template's offline window is five times interval_s, and at least 5 minutes. A template that you picked yourself is never replaced.
  • It creates a dashboard named after the device, the first time the device announces a numeric property other than rssi, uptime_s and heap_free. If you delete the dashboard, it is not created again.
  • It saves the firmware name and version, the chip and the sensors. They show in the Details card on the device page.

Errors: 400 with {"error":"invalid_announcement","issues":[…]} when a field does not fit the table, and 401 with {"error":"unauthorized"} for wrong credentials.

Sensora is open source under the Apache 2.0 license.