Bulk Delete Devices

This endpoint deletes one or more Device(s) at once.

❗️

+++Attention+++

This endpoint is extremely powerful. But with great power comes a great responsibility.

Deleting Devices CANNOT be undone. Please backup any device and variable data before deleting a Device.

Request

To delete one or more Devices please make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v2.0/devices/_/bulk/delete/

🚧

It's a POST

Please note that it's a POST request and not a DELETE request.

Body Parameters

The body is an Array containing one or more <device_key>. Each <device_key> object can contain the following body parameters:

ParameterTypeDescription
device_keyStringThe id or label of the Device, label should use the prefix ~

📘

<device_key>

Remember that the <device_key> has 3 valid formats:
-<device_id> : "6e309da44fc8455a9cceb5aa"
-<device_label>: "~second-device" //Remember to add the ~ before the device label
-JSON of <device_id>: { "id": "1237809ca5pIhpjgc345fc" }

❗️

+++ATTENTION+++

Please be VERY careful using this endpoint, why? Because it's possible to delete many Devices at once.

We propose 1 safe alternatives:

  • Do a GET All Devices request using the query parameter fields=id. This returns an Array of the Device Ids. Simply copy this Array and use it in the body for this endpoint. Thus, you make sure that only the intended Devices in that Array are deleted and not any other.

Query Parameters

ParameterTypeUseDescription
tokenStringAuthenticationAuthentication Token can optionally be sent as a query parameter

Header

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of account
X-Bulk-OperationYesNeed to be set to True for the bulk operation to work
Content-TypeYesContent type of body
$ curl -X DELETE 'https://industrial.api.ubidots.com/api/v2.0/devices/_/bulk/delete/' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -H 'Content-Type: application/json' \
 -H 'X-Bulk-Operation: True' \
 -d '[
  "6e309da44fc8455a9cceb5aa",
  "~second-device",
  "~third-device",
  {
    "id": "1237809ca5pIhpjgc345fc"
  }
]'
{
  "task": {
    "id": "tyg54645501a9ca5714e7b098721"
  }
}
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        ....
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided.",
    "detail": "Authentication credentials were not provided."
}
{
    "detail": "Header `X-BULK-OPERATION` should be provided for bulk operation."
}

Response

Returns a Task Id of the asynchronous process.