Skip to content
Stand with Ukraine flag

Provisioning

Device Provisioning lets devices register themselves dynamically without being created manually in the ThingsBoard UI. For a full explanation, see Provisioning.

All provisioning requests are sent to a single endpoint — no access token is required:

POST coap://THINGSBOARD_HOST:5683/api/v1/provision

The request body identifies the device and the provisioning profile configured in ThingsBoard.

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"
}
Terminal window
coap-client -v 6 -m POST -t "application/json" -e '{"deviceName":"DEVICE_NAME","provisionDeviceKey":"PUT_PROVISION_KEY_HERE","provisionDeviceSecret":"PUT_PROVISION_SECRET_HERE"}' "coap://$THINGSBOARD_HOST:5683/api/v1/provision"

Response:

{
"status": "SUCCESS",
"credentialsType": "ACCESS_TOKEN",
"credentialsValue": "sLzc0gDAZPkGMzFVTyUY"
}

Use credentialsValue as the access token for subsequent CoAP API requests.

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"
}
Terminal window
coap-client -v 6 -m POST -t "application/json" -e '{"deviceName":"DEVICE_NAME","provisionDeviceKey":"PUT_PROVISION_KEY_HERE","provisionDeviceSecret":"PUT_PROVISION_SECRET_HERE","credentialsType":"ACCESS_TOKEN","token":"DEVICE_ACCESS_TOKEN"}' "coap://$THINGSBOARD_HOST:5683/api/v1/provision"

Response:

{
"status": "SUCCESS",
"credentialsType": "ACCESS_TOKEN",
"credentialsValue": "DEVICE_ACCESS_TOKEN"
}
FieldRequiredDescription
deviceNameNoName of the device to create. A name is auto-generated if omitted.
provisionDeviceKeyYesProvisioning key from the device profile in ThingsBoard.
provisionDeviceSecretYesProvisioning secret associated with the key.
credentialsTypeNoSet to ACCESS_TOKEN to specify a custom token.
tokenNoThe access token to assign when credentialsType is ACCESS_TOKEN.