Provisioning
Device Provisioning lets devices register themselves dynamically without being created manually in the ThingsBoard UI. For a full explanation, see Provisioning.
Provisioning Endpoint
Section titled “Provisioning Endpoint”All provisioning requests are sent to a single endpoint — no access token is required:
POST http(s)://THINGSBOARD_HOST/api/v1/provisionThe request body identifies the device and the provisioning profile configured in ThingsBoard.
Provisioning Strategies
Section titled “Provisioning Strategies”Without Credentials
Section titled “Without Credentials”ThingsBoard generates and returns an access token for the new device.
Request:
{ "deviceName": "DEVICE_NAME", "provisionDeviceKey": "PUT_PROVISION_KEY_HERE", "provisionDeviceSecret": "PUT_PROVISION_SECRET_HERE"}curl -s -X POST -H "Content-Type: application/json" -d '{"deviceName":"DEVICE_NAME","provisionDeviceKey":"PUT_PROVISION_KEY_HERE","provisionDeviceSecret":"PUT_PROVISION_SECRET_HERE"}' "http://$THINGSBOARD_HOST/api/v1/provision"Response:
{ "status": "SUCCESS", "credentialsType": "ACCESS_TOKEN", "credentialsValue": "sLzc0gDAZPkGMzFVTyUY"}Use credentialsValue as the access token for subsequent HTTP API requests.
With Specific Access Token
Section titled “With Specific Access Token”The device specifies its own access token during provisioning. ThingsBoard creates the device with the provided token.
Request:
{ "deviceName": "DEVICE_NAME", "provisionDeviceKey": "PUT_PROVISION_KEY_HERE", "provisionDeviceSecret": "PUT_PROVISION_SECRET_HERE", "credentialsType": "ACCESS_TOKEN", "token": "DEVICE_ACCESS_TOKEN"}curl -s -X POST -H "Content-Type: application/json" -d '{"deviceName":"DEVICE_NAME","provisionDeviceKey":"PUT_PROVISION_KEY_HERE","provisionDeviceSecret":"PUT_PROVISION_SECRET_HERE","credentialsType":"ACCESS_TOKEN","token":"DEVICE_ACCESS_TOKEN"}' "http://$THINGSBOARD_HOST/api/v1/provision"Response:
{ "status": "SUCCESS", "credentialsType": "ACCESS_TOKEN", "credentialsValue": "DEVICE_ACCESS_TOKEN"}Request Fields
Section titled “Request Fields”| Field | Required | Description |
|---|---|---|
deviceName | No | Name of the device to create. A name is auto-generated if omitted. |
provisionDeviceKey | Yes | Provisioning key from the device profile in ThingsBoard. |
provisionDeviceSecret | Yes | Provisioning secret associated with the key. |
credentialsType | No | Set to ACCESS_TOKEN to specify a custom token. |
token | No | The access token to assign when credentialsType is ACCESS_TOKEN. |