Replace Device

Overview

A Device replacement lets a Device that is already registered register again without losing
its identity
: its id, history, telemetry, configuration and the End Customer's claim all stay.
It covers a failed unit swapped for a new one of the same Model, and a unit that was factory reset
and lost its id and access_key.

Nothing changes on the Device side: firmware calls Register Device exactly as
on first boot. What changes is on the server — an operator has staged the replacement, so the
registration is accepted and the existing Device record is reused instead of being refused.

Why a second registration is refused

While a Device exists, registering again under the same identity — cloud_id, or mac and sn,
depending on the Model's authentication method — returns
422 — Device already registered, with no error_code:

{ "error": "Device already registered" }

The server also flags the existing Device in the Organization portal with an Approval required
badge. The flag is stamped at most once per throttling interval, so there is nothing to gain from
registering in a tight loop: back off and keep retrying until the registration is accepted (see
Error handling).

📘

Child devices cannot be replaced

A Device registered under a parent (Application Devices) gets the same
422, but no flag is raised and no replacement can be staged for it.

How a replacement is staged

A replacement is a pending identifier stored on the existing Device record: the serial number
or Cloud ID the next registration is expected to present. An operator sets it in one of two ways.

In the Organization portal, Manage → Replace device on the existing Device, entering the new
unit's serial number or Cloud ID — whichever the Model authenticates by. The same action is
available to the partner from the Device attached to a support ticket. Portal procedure:
Replace a device in the customer docs.

⚠️

The new unit must not already be registered

A replacement completes when the new unit registers. A unit that already holds valid
credentials never calls Register Device again, so the pending replacement will not trigger.
Delete that unit's own Device record first; when it registers afresh, the replacement picks it up.

Staging a replacement immediately revokes the Device's licenses (they stay attached and re-activate
once it reconnects; platform licenses in use stay active), aborts its active commands and closes
its open incidents.

What happens on the next registration

On POST /v1/devices the server, before the uniqueness check, looks for a Device of the same
Model whose pending identifier matches the request — the pending serial number against sn, or the
pending Cloud ID against cloud_id. The match is exact and case-sensitive after trimming
surrounding whitespace. When it matches:

  • The existing record takes the registering unit's sn, mac, cloud_id, firmware_version,
    sub_model, details, hardware_key and host_address (and its certificate, for X.509 Models),
    and the pending identifier is cleared.
  • The access_key is regenerated; any credentials the old unit still holds stop working. For
    MQTT based devices the broker authorization is refreshed as well.
  • The response is the standard 201 of Register Device. The id is the
    same Device id as before — only access_key is new. Persist it before use, as on a first
    registration.
  • replacement_initiated and replacement_completed events are written to the Device's history.

The same handling applies to every entry of a Bulk Register Devices
request.

Replacement versus deleting the Device

Both let a unit register again; they differ in what survives.

ReplacementDelete Device
Device idKeptNew Device, new id
History, telemetry, configurationKeptLost
End Customer's claimKeptLost — the Device must be claimed again
access_keyRe-issuedIssued for the new Device
What is freedNothingThe cloud_id (and the certificate, for X.509 Models): uniqueness is enforced among live Devices only, so a fresh registration succeeds as if the unit were new

Delete when a unit changes owner. Replace when the unit, or its successor, should carry on as the
same Device.

X.509 Models

For Models whose authentication method is X.509 Certificate the two-step challenge described on
Register Device runs as usual; the replacement decision is made on the
signed retry.

A reset unit re-presents its own certificate. It is deliberately not refused with
certificate_already_registered — that check only fires when the certificate is bound to a Device
with a different cloud_id — so the signed retry reaches the replacement handling: 422 until a
replacement is staged, accepted once it is.

Firmware checklist

  • Treat 422 — Device already registered as "wait for an operator": back off and keep retrying
    registration at a sensible interval.
  • On 201, persist the returned access_key before using it. The id is unchanged after a
    replacement, but always store what the response returns.
  • Never keep using credentials saved before a reset; they are revoked when the replacement completes.