Device API¶
The endpoints ESP32 devices call. Both accept either a project token
(with device_id in the request body) or a per-device token (issued
from the dashboard's device detail page).
Hardware-safe responses.
/check/returns200with astatusfield for business outcomes (no update available, plan over limit, device deactivated). Devices retry/check/errors, which is why those outcomes stay200./status/returns400when the deployment hasn't been started, and a 1.0 client counts any HTTP response to a status POST as delivered, that400included.
POST /api/v1/ota/check/¶
Asks SimpleOTA "is there an update for me?" and reports a heartbeat.
Request¶
{
"device_id": "esp32-demo-0001",
"framework": "arduino",
"chip_family": "esp32",
"board_id": "esp32dev",
"current_build_number": 17,
"version_label": "1.4.1", // display label only, not used for compatibility
"current_hash": "8f3c…",
"hardware_revision": "rev-a",
"partition_profile": "default_4mb",
"nvs_schema_version": 2,
"security_mode": "basic"
}
| Field | Required | Notes |
|---|---|---|
device_id |
✅ | Stable per unit. Required in project-token mode. With a device token, a check-in saves it on a device created without one, unless another device in the project holds it or it is over 64 characters; the response is the same whatever ID is sent. |
framework |
✅ | arduino or esp_idf. |
chip_family |
✅ | esp32, esp32s3, esp32c3, etc. |
current_build_number |
✅ | The build_number from the last /check/ offer that the device successfully installed, persisted in NVS. Send 0 on a factory-fresh device. Never use your own internal build counter here. See Build numbers. |
board_id |
Required if your artifacts declare it. | |
hardware_revision |
Required if your artifacts declare it. | |
version_label |
Display label for the firmware currently running (e.g. "1.4.1"). Stored on the device record and shown in the dashboard under Reported firmware state → Version label. Not used in compatibility checks or update eligibility. It is purely for human visibility. Read from NVS after installation. |
|
current_hash |
SHA-256 hex digest of the currently-running binary. Stored on the device record and shown in the dashboard under Reported firmware state → Binary SHA-256. Read from NVS after installation. | |
partition_profile |
Partition table layout the device is using (e.g. default_4mb, min_spiffs). Enforced when the artifact declares a profile: a mismatch blocks the update. Omit or leave blank if your firmware does not use partition-scoped images; blank always matches. |
|
nvs_schema_version |
Integer NVS schema version currently written to flash. Enforced when the artifact declares a minimum version: if device < artifact, the update is blocked to prevent NVS data corruption. Device may omit this field; omitting always matches. |
|
security_mode |
Optional. Report basic or signed when your firmware opts in; enforced when the artifact declares a mode (a mismatch blocks the update). Omit or leave blank if your firmware does not differentiate; blank always matches on this dimension. A legacy token value in the body is ignored and is not stored. |
|
require_manifest |
Optional. true when the device is in strict mode and takes strict-ready builds only; such a device is offered nothing else. Send it on every check-in: a check-in without it stores false. |
A channel value in this body is ignored. Auto-registered devices land on the project's default release channel, and a later move is done from the dashboard or the developer API. See Release channels.
Response: update available¶
{
"update_available": true,
"build_number": 23,
"version": "1.4.2",
"url": "https://<bucket>/firmware/<key>?X-Amz-Signature=…",
"checksum": "8f3c…",
"size": 1287456,
"deployment_id": "9a1c…",
"security_mode": "basic"
}
The device should download url, verify checksum (SHA-256), install,
then call /status/.
A signed offer also carries signing_key_id, signature_algorithm and
signature. When the build is
strict-ready, it carries
manifest_signature (base64 Ed25519) and manifest_version (1) too;
otherwise both are null.
Response: no update¶
{
"update_available": false,
"status": "up_to_date",
"message": "Device is already on the latest compatible build."
}
status values:
status value |
Meaning |
|---|---|
up_to_date |
Device is at the highest assigned compatible build. |
no_active_deployment |
No active deployment is left to offer this device. A deployment the device has rolled back with no retries left doesn't count. |
not_in_rollout |
Eligible, but cohort bucket is above the current percentage. |
no_compatible_build |
Deployments target the device's audience but no artifact is hardware-compatible. |
over_limit |
Plan device cap reached; auto-registration refused. |
device_inactive |
Device record exists but is active = false. |
HTTP status codes¶
| Code | When |
|---|---|
200 |
All business outcomes, including no-update. |
400 |
Malformed request body. |
401 |
Missing/invalid project token. |
403 |
Token belongs to a different project. |
5xx |
Genuine server failure. Devices may retry. |
POST /api/v1/ota/status/¶
Reports an OTA lifecycle event for the calling device.
Request¶
{
"device_id": "esp32-demo-0001",
"deployment_id": "9a1c…",
"event": "confirmed",
"build_number": 23,
"reason": null,
"detail": null
}
| Field | Required | Notes |
|---|---|---|
device_id |
✅ | Required in project-token mode so we know which device the event is for. |
deployment_id |
✅ | The deployment the event pertains to. |
event |
✅ | See event vocabulary below. |
build_number |
Required with confirmed so SimpleOTA can advance the device's recorded build. |
|
reason |
Short token explaining the outcome, especially for failed and rolled_back. The first 128 characters are kept. |
|
detail |
Optional JSON object with extra structured detail. On a terminal event, one over 4096 bytes as JSON, nested more than 32 levels deep, or holding NaN or an infinite number is stored as {"truncated": true}. A body that cannot be parsed (extreme nesting, an integer over 4300 digits) gets 400, and a detail that is not an object gets 422. |
A NUL character or a lone UTF-16 surrogate in reason or detail is stored
as U+FFFD, and the report is accepted. Only terminal events keep detail.
Event vocabulary (v0.2+)¶
Events in canonical order for a successful update:
| Event | When | Terminal? | Idempotent? |
|---|---|---|---|
offered |
Device acknowledged the offer | ||
download_started |
Firmware download began | ||
downloaded |
Binary fully received | ||
flashed |
Written to flash | ||
validated |
Image committed to NVS (informational) | ||
reboot |
Emitted immediately before esp_restart() |
||
confirmed |
Device booted new image and called simpleota_confirm() |
✅ yes | ✅ yes |
failed |
simpleota_apply() refused the offer before download, or the download or flash failed |
✅ yes | |
rolled_back |
Trial ended without confirm; device is on the previous build again | ✅ yes | ✅ yes |
The legacy rebooted event (fired by v0.1 devices after booting the new image) is still accepted.
1.0 clients store confirmed and rolled_back in NVS. Any HTTP response
to that POST, 400 included, counts as delivered, so the client doesn't
send it again. A POST that gets no response stays pending and goes out
again on later checks, first with a few quick retries and then at the
normal check interval. A repeat of the same terminal event within one
attempt is idempotent.
A download_started on a failed row opens a new attempt in the same
deployment, and a confirmed for the deployment's build is accepted as that
attempt's result. A rolled_back row reopens on download_started while its
rollback count is within the deployment's retries allowed. Each failed
attempt writes its own audit event, up to five per device and deployment.
The fifth has "failure_log_capped": true and a note saying later failures
are not logged.
Failure and rollback reasons¶
reason is a short token (keep it under ~64 chars, lowercase, snake_case).
The dashboard shows it on the device row and in the per-device timeline.
1.0 clients use the vocabulary below so fleets stay comparable across
firmware versions.
With event failed, posted from simpleota_apply() (a refusal is before any download): downgrade_refused
(offer not above the running build), insecure_url, signature_invalid,
https_begin_failed, http_status_<N> (HTTP status N, including the 3xx that
would have been a fourth redirect),
redirect_not_https, redirect_malformed, update_begin_failed (no second OTA
slot or image too large), update_write_failed, stream_error,
download_stalled (no progress for the HTTP timeout), short_read,
checksum_mismatch, update_end_failed, state_save_failed.
With event rolled_back: confirm_timeout (the client's confirm timer ended
the trial), or the reset that ended the trial: panic, int_wdt, task_wdt,
watchdog, brownout, power_on, deep_sleep, reset.
A burst of signature_invalid across a fleet is a security signal, not a
flakiness signal: it means devices are rejecting an image they were
offered. Pause the deployment and investigate the key and pipeline before
anything else.
Response¶
A confirmed event is the terminal success signal: the device has booted the new image,
called simpleota_confirm(), and is operating normally. SimpleOTA updates the device's recorded
current_build_number to the build_number in this payload.
failed or rolled_back events surface the reason string in the
dashboard and increment the deployment's failure counter.
A deployment that has not been started returns HTTP 400:
That is a draft, or a deployment cancelled with no started_at. The
report does not change device state, rollback counters, auto-pause, or
rollout stats. Paused, cancelled, and completed deployments that have
started_at set still accept a late report.