From 54a4f847081e8949717946434872b5a7fc4e1d0f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 22 Sep 2020 10:18:15 -0400 Subject: [PATCH] Add REST API documentation for bulk object deletion --- docs/rest-api/overview.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/rest-api/overview.md b/docs/rest-api/overview.md index d16cd059d..34ea7c12f 100644 --- a/docs/rest-api/overview.md +++ b/docs/rest-api/overview.md @@ -529,3 +529,17 @@ Note that `DELETE` requests do not return any data: If successful, the API will !!! note You can run `curl` with the verbose (`-v`) flag to inspect the HTTP response codes. + +### Deleting Multiple Objects + +NetBox supports the simultaneous deletion of multiple objects of the same type by issuing a `DELETE` request to the model's list endpoint with a list of dictionaries specifying the numeric ID of each object to be deleted. For example, to delete sites with IDs 10, 11, and 12, issue the following request: + +```no-highlight +curl -s -X DELETE \ +-H "Authorization: Token $TOKEN" \ +http://netbox/api/dcim/sites/ \ +--data '[{"id": 10}, {"id": 11}, {"id": 12}]' +``` + +!!! note + The bulk deletion of objects is an all-or-none operation, meaning that if NetBox fails to delete any of the specified objects (e.g. due a dependency by a related object), the entire operation will be aborted and none of the objects will be deleted.