Claiming
Device claiming transfers a device from the tenant’s account to a specific customer. A manufacturer ships thousands of devices pre-provisioned under the tenant — then each end customer claims their own unit using a secret key. Once claimed, the customer becomes the device’s owner: the device leaves all of the tenant’s device groups and is added to the customer’s All group.
There are two scenarios depending on what the device can do. Both end the same way: a customer user enters the device name and secret key in the Device claiming widget or calls the REST API, and ownership transfers.
Device-Side Claiming
Section titled “Device-Side Claiming”Use this when the device has a display, button, or indicator and can show the customer a code at setup time — for example, a Wi-Fi thermostat that shows a PIN on its screen during first boot, or a smart meter with a QR code generated on demand. The device generates a secret key on a trigger and publishes it to ThingsBoard; the customer reads it directly off the device and claims it.
1. Enable Claiming
Section titled “1. Enable Claiming”On ThingsBoard Cloud, claiming is enabled for all devices: any device that doesn’t belong to a customer can publish claiming data. No setup is needed.
2. Device Publishes the Claiming Key
Section titled “2. Device Publishes the Claiming Key”The device sends the following payload over any supported transport (MQTT, HTTP, CoAP):
{ "secretKey": "your-secret", "durationMs": 60000}secretKey— the secret customers must provide. Optional; if omitted, the key is an empty string.durationMs— how long the key is valid, in milliseconds. Optional; if omitted, the system default applies.
ThingsBoard holds one pending key per device in its claim cache, not in a device attribute:
- If the device already belongs to a customer, the key is ignored. The device still gets a normal acknowledgment (MQTT PUBACK, HTTP
200, CoAP2.01), so it can’t tell that the key was ignored. - The key is removed by a successful claim, by any failed claim attempt (a wrong key, or the right key after it expired), and by reclaiming the device. After a failed attempt, the device must publish a key again.
- The key stays in the cache after
durationMspasses. Until one of these events removes it, any new key the device publishes is ignored, so keep showing the first key instead of generating a new one.
3. Customer Claims the Device
Section titled “3. Customer Claims the Device”A customer user opens a dashboard with the Device claiming widget (from the Input widgets bundle), enters the device name and the secret key shown on the device, and clicks Claim device. The user can also call the REST API.
If the device publishes no secretKey, turn off Show ‘Secret key’ input field in the widget settings; otherwise, the widget requires a key.
Server-Side Claiming
Section titled “Server-Side Claiming”Use this when the device has no UI at all — NB-IoT sensors, LoRaWAN trackers, or any device auto-provisioned via Platform Integrations that the customer never physically interacts with. The tenant generates secrets in advance and includes them in the product packaging, a welcome email, or a customer portal; the customer never touches the device to get the code.
1. Upload the Claiming Data
Section titled “1. Upload the Claiming Data”For each device, set a server-side attribute named claimingData with a JSON value:
{ "secretKey": "your-secret", "expirationTime": 1735689600000}secretKey— the secret to distribute to the customer. Optional; if omitted, the customer claims the device with an empty key.expirationTime— Unix timestamp in milliseconds after which claiming is no longer allowed. Required: without it, every claim attempt fails.
Use only these two fields: any other field makes the claim request fail.
Add the attribute in the UI (open the device ⇢ Attributes ⇢ Server attributes ⇢ +, value type JSON) or in bulk via the REST API.
A wrong key leaves claimingData in place, so the customer can try again. Once expirationTime passes, upload new claimingData. After a successful claim, ThingsBoard deletes it.
If the device has also published a key that is still pending (see Device-Side Claiming), that key takes priority, and claimingData is ignored.
2. Distribute the Key
Section titled “2. Distribute the Key”Send the device name and secret key to the customer through any external channel. The customer will need both to complete claiming.
3. Customer Claims the Device
Section titled “3. Customer Claims the Device”Same as device-side: a customer user enters the device name and secret key in the Device claiming widget or calls the REST API. If claimingData has no secretKey, turn off Show ‘Secret key’ input field in the widget settings.
Who Can Claim Devices
Section titled “Who Can Claim Devices”Only customer users can claim devices. The user needs a generic role that grants Claim devices (or All) on devices. By default, the customer’s Customer Administrators group has it, and Customer Users doesn’t.
Tenant users can’t claim devices, but they can reclaim them if their role grants Claim devices, as the default Tenant Administrators group does.
Claiming via REST API
Section titled “Claiming via REST API”A customer user can claim a device programmatically:
POST /api/customer/device/{deviceName}/claimContent-Type: application/json
{"secretKey": "your-secret"}Always send a JSON body; use {} if the device has no secret key.
| Status | Body | Meaning |
|---|---|---|
200 |
{"device": {...}, "response": "SUCCESS"} |
The device is claimed and now belongs to the user’s customer |
400 |
"FAILURE" |
The key is wrong or expired, or the device has no claiming data |
400 |
"CLAIMED" |
The device already belongs to the user’s customer or one of its sub-customers |
403 |
Error message | The user’s role doesn’t grant Claim devices, or the device belongs to another customer |
404 |
Error message | No device with this name, or subCustomerId isn’t a sub-customer of the user’s customer |
To claim the device for a sub-customer of the user’s customer, add ?subCustomerId={subCustomerId} to the POST request. The device then joins that sub-customer’s All group. The Device claiming widget doesn’t support this.
Reclaiming a Device
Section titled “Reclaiming a Device”To return a device to the tenant (remove customer ownership):
DELETE /api/customer/device/{deviceName}/claimUsers whose role grants Claim devices can reclaim a device: tenant users any device of the tenant, customer users any device owned by their customer or its sub-customers. The device leaves the customer’s groups and is added to the tenant’s All group; the groups it belonged to before claiming aren’t restored. A pending device-side key is discarded.
For server-side claiming, upload new claimingData before the device can be claimed again: reclaiming doesn’t restore it.
Was this helpful?