Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors

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.

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.

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.

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, CoAP 2.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 durationMs passes. 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.

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.

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.

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.

Send the device name and secret key to the customer through any external channel. The customer will need both to complete claiming.

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.

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.

A customer user can claim a device programmatically:

POST /api/customer/device/{deviceName}/claim
Content-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.

To return a device to the tenant (remove customer ownership):

DELETE /api/customer/device/{deviceName}/claim

Users 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.