Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api-reference/storage/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@
"required": true,
"description": "The API AccessKey used for authentication.",
"schema": { "type": "string" }
},
{
"name": "allowRootDelete",
"in": "query",
"required": false,
"description": "Set to `true` to bypass the root directory deletion guard and delete the storage zone root (`/`).",
"schema": { "type": "string", "enum": ["true"] }
},
{
"name": "allowRootDelete",
"in": "header",
"required": false,
"description": "Set to `true` to bypass the root directory deletion guard and delete the storage zone root.",
"schema": { "type": "string", "enum": ["true"] }
}
],
"responses": {
Expand Down
33 changes: 32 additions & 1 deletion storage/http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,41 @@ Returns a JSON array of files and directories.

## Delete a file

Delete files using a DELETE request:
Delete files or directories using a DELETE request. Deleting a directory recursively removes all of its contents.

```bash
curl -X DELETE \
https://storage.bunnycdn.com/your-zone-name/path/to/file.jpg \
-H "AccessKey: your-storage-password"
```

### Deleting the root directory

By default, deleting the root directory (`/`) is blocked as a safety guard. To bypass this protection, include `allowRootDelete=true` as either a query string parameter or a request header.

<Warning>
Deleting the root directory permanently removes **all files and directories** in your storage zone. This action cannot be undone.
</Warning>

**Via query string parameter:**

- Key: `allowRootDelete`
- Value: `true`

```bash
curl -X DELETE \
"https://storage.bunnycdn.com/your-zone-name/?allowRootDelete=true" \
-H "AccessKey: your-storage-password"
```

**Via request header:**

- Name: `allowRootDelete`
- Value: `true`

```bash
curl -X DELETE \
https://storage.bunnycdn.com/your-zone-name/ \
-H "AccessKey: your-storage-password" \
-H "allowRootDelete: true"
```