Skip to main content

HTTPS provisioning

The device calls POST {IOTMER_PROVISION_API_URL}/provision/device and stores the JSON response in NVS as iotmer_creds_t.

Console setup (workspaces, API keys): docs.iotmer.com

When HTTPS runs​

ConditionResult
IOTMER_PROVISION_AUTH_CODE setHTTPS provision runs (requires IOTMER_WORKSPACE_ID)
Auth code empty + complete NVS sessionHTTPS skipped — field firmware path

Complete NVS session: device_id, device_key, workspace_slug, mqtt_host, mqtt_username, mqtt_password.

device_http_token (NVS key dht) is not required for MQTT. It is required for iotmer_device_auth_bind_claim(). If HTTPS was skipped and NVS has no dht, run a one-off provision with auth code, or set lab-only IOTMER_DEVICE_HTTP_TOKEN.

Request​

POST /api/v1/provision/device · Header: iotmer-auth-code

FieldRequiredSource
workspace_idYesKconfig IOTMER_WORKSPACE_ID
device_keyFirst registrationcreds->device_key before call
template_idNoKconfig IOTMER_TEMPLATE_ID
device_idNoNVS (re-provision)

First registration:

{"workspace_id":"ws_...","device_key":"IoTmer-GW-3B7C"}

Re-provision:

{"workspace_id":"ws_...","device_key":"IoTmer-GW-3B7C","device_id":"dev_..."}

Response (parsed fields)​

FieldUse
device_id, device_keyIdentity
workspace_slugMQTT topic prefix → NVS
mqtt_host, mqtt_port, mqtt_tls, mqtt_username, mqtt_passwordBroker session
device_http_tokenBearer for POST …/devices/auth/* → NVS dht. Never log.
firmware_url, firmware_checksum_sha256, firmware_size_bytesHTTP(S) auto-OTA (OTA)

Responses may nest fields under data — the SDK handles both layouts.

Bind-claim​

Deliver claim_code out-of-band (often over BLE JSON). Device calls:

POST …/devices/auth/bind-claim with Authorization: Bearer {device_http_token}

HTTPSDK result
200 + ok: trueESP_OK
401ESP_ERR_INVALID_ARG
409 / 410ESP_ERR_INVALID_STATE (used/expired claim)

See BLE JSON provisioning and examples/05_ble_json.

Logging​

After successful parse, the SDK logs host, port, TLS, username, password length, and whether the password changed. Password and token values are never logged.

OTA flag​

On HTTPS success, the SDK sets an internal https_performed flag so OTA can run even when SHA matches NVS. See OTA.