# IoT device provisioning: from factory to customer

> IoT device provisioning covers identity, registration, Wi-Fi onboarding and claiming. How we design each stage from factory line to customer account.

- Author: Milo Perović, Founder & lead engineer
- Published: 2026-11-06
- Topic: Software

Most connected products get IoT device provisioning wrong in the same way: it is treated as a setup screen in the app, designed in the last month before launch. In reality it starts on the factory line, where each device needs an identity, and ends when a customer's account owns that device and it is talking to your backend with its own credentials.

This post is for founders and engineers planning a first production run of a Wi-Fi, BLE or cellular device.

## What provisioning actually covers

People use "provisioning" for at least four different jobs. Each happens at a different time, in a different place.

- **Identity:** giving each unit a unique, unforgeable identity, usually a key pair and certificate, plus a serial number.

- **Registration:** telling the backend that this identity exists and is allowed to connect.

- **Network onboarding:** getting Wi-Fi credentials, a LoRaWAN join, or a SIM activated so the device can reach the internet.

- **Claiming:** binding the device to a specific customer account, so the right person sees its data and nobody else does.

The first two belong to manufacturing, the last two to the customer's first five minutes. Mixing them, for example generating keys during app setup, causes most of the security and support problems.

## Device identity: keys, certificates and where they live

Every unit should have its own credentials. A shared password or API key baked into the firmware image means one extracted unit compromises the whole fleet.

The common pattern is mutual TLS with an X.509 client certificate per device. The private key is either generated on the device during production, so it never leaves the chip, or generated by a provisioning station and injected. In the on-device case, the device produces a signing request, the station signs it with an intermediate CA you control, and only the certificate travels over the factory network.

Where the key is stored matters as much as how it was made:

- **Plain flash:** fine for prototypes, weak in production. Anyone with a debug probe and an unlocked chip can read it.

- **Encrypted flash with secure boot:** on parts such as the ESP32-S3 or STM32 families with readout protection, this raises the bar considerably at no extra BOM cost, provided debug access is locked on production units.

- **Secure element:** a separate chip such as the Microchip ATECC608 keeps the private key in hardware and performs signing internally. It adds a component and cost per unit.

For most small-batch products, encrypted flash with secure boot and locked debug is the sensible default. A secure element earns its place when devices control something physical, sit in untrusted locations or need to meet a customer's security review.

## Registration on the production line

Once a unit has an identity, the backend needs to know about it.

**Pre-registration** means the provisioning station uploads each device's certificate and serial to your backend as it is built. The backend only accepts known devices. This is the tightest model, but the factory needs a link to your systems or a batch import.

**Registration on first connect** means the backend trusts any certificate signed by your production CA, and creates the device record the first time it connects. AWS IoT, for instance, supports this through just-in-time registration and fleet provisioning. It decouples factory from cloud, but your CA key becomes the crown jewel.

Either way, provisioning should be part of end-of-line test, not a separate station. We fold key generation, certificate signing and a first test connection into the same fixture run described in our post on [end-of-line testing for your first production batch](https://miloperovic.com/journal/end-of-line-testing-for-your-first-production-batch/). A unit that fails to provision fails the test, and the log records serial, certificate fingerprint and firmware version.

## Network onboarding in the customer's hands

For cellular and LoRaWAN devices, onboarding is mostly a backend concern: SIM activation or registering the DevEUI with the network server. For Wi-Fi, the customer has to hand over a network name and password, and this is where the user experience is won or lost.

MethodHow it worksMain trade-off

BLE onboardingApp connects over BLE, sends credentials over an encrypted sessionSmoothest flow, needs BLE in hardware and app permissions

SoftAPDevice hosts its own access point, phone joins it, app or web page sends credentialsNo BLE needed, but phones often drop the connection to a network without internet

QR code or setup codeCode on the device or packaging carries a proof-of-possession secret used during onboardingStops neighbours hijacking setup, adds a packaging and labelling step

Espressif's ESP-IDF includes a provisioning framework that supports both BLE and SoftAP transports with a proof-of-possession secret. Whatever you use, the device should report specific failure reasons back to the app: wrong password, network not found, no DHCP lease, no route to the broker. "Setup failed" alone generates support tickets.

Two details matter early. Most low-cost Wi-Fi modules support only 2.4 GHz, so the app should say so before the user picks a network. And the device needs a clear, physical way back into setup mode, because people change routers.

## Claiming: binding a device to an account

Claiming answers one question: who owns this unit? The backend should only bind a device to an account when the person can prove physical possession. Common proofs are a claim code printed inside the box, a code read over BLE during setup, or a short-lived token that the device itself fetches from the backend and passes to the app.

The design decisions that cause trouble later are about change of ownership:

- What happens when a device is sold second-hand or returned and resold?

- Can an account share a device with other users, and with what permissions?

- Does a factory reset release the claim, or only clear Wi-Fi credentials?

- How does support release a device for a customer who has lost access to the original account?

We keep device identity and ownership separate in the data model. The device record and its certificate stay constant for the life of the hardware. The ownership record changes. It also keeps MQTT permissions simple: a device publishes under its own ID and the backend decides which accounts see that data, following the structure in our post on [MQTT topic design for a growing device fleet](https://miloperovic.com/journal/mqtt-topic-design-for-a-growing-device-fleet/).

## Failure modes we plan for in IoT device provisioning

Every unit goes through provisioning, so its edge cases show up quickly at scale. The ones we design around:

- **Interrupted setup:** power lost or the app closed halfway. The device must return to a clean, retryable state rather than a half-configured one.

- **Clock not set:** certificate validation needs a roughly correct time. A device with no RTC battery may need to sync time before its first TLS connection, or use a validity window that tolerates it.

- **Certificate expiry:** device certificates issued with short lifetimes need a renewal path in firmware. Long lifetimes avoid that, at the cost of weaker revocation.

- **Re-flashed units:** RMA and rework must not wipe the identity partition, or the unit comes back as a stranger to your backend.

- **Production CA compromise:** keep the CA key off the factory PC, ideally in a hardware security module or a managed CA service, and be able to revoke by batch.

## What we would do on a first production run

Before committing to a factory process, we would work through this list:

- Write down the four stages (identity, registration, onboarding, claiming) and who owns each one.

- Choose per-device credentials and decide where the private key lives. Never ship a shared secret.

- Lock debug access and enable secure boot on production units, and test that a locked unit can still be updated over the air.

- Fold provisioning into end-of-line test and log every result against the serial number.

- Pick one onboarding method, design the error messages, and test it on a range of real phones and routers.

- Model ownership separately from identity, and decide what factory reset and resale do before launch.

- Rehearse revoking a single device and a whole batch on staging.

None of this is exotic, but it spans hardware, firmware, factory tooling, backend and app, which is why it falls between teams. Settle it during architecture, not the week before units ship.
