> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pterodactyl/wings/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Files

> Delete one or more files or directories from the server

## Endpoint

```
POST /api/servers/:server/files/delete
```

## Authentication

Requires Bearer token authentication via the `Authorization` header.

## Path Parameters

<ParamField path="server" type="string" required>
  The UUID of the server
</ParamField>

## Request Body

<ParamField body="root" type="string" required>
  The root directory for delete operations (all paths are relative to this)
</ParamField>

<ParamField body="files" type="string[]" required>
  Array of file/directory paths to delete (relative to root)
</ParamField>

## Response

Returns `204 No Content` on success.

## Example Request

<CodeGroup>
  ```bash cURL - Single File theme={null}
  curl -X POST "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/delete" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "root": "/",
      "files": ["old-log.txt"]
    }'
  ```

  ```bash cURL - Multiple Files theme={null}
  curl -X POST "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/delete" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "root": "/logs",
      "files": [
        "debug.log",
        "error.log",
        "old-logs/"
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(
    'https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/delete',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        root: '/',
        files: ['cache/', 'temp.dat', 'old-config.yml']
      })
    }
  );
  ```

  ```python Python theme={null}
  import requests

  requests.post(
      'https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/delete',
      headers={'Authorization': 'Bearer YOUR_TOKEN'},
      json={
          'root': '/backups',
          'files': ['old-backup.tar.gz', 'outdated/']
      }
  )
  ```
</CodeGroup>

## Behavior

* Both files and directories can be deleted
* Directories are deleted recursively (all contents removed)
* Operations are performed concurrently for better performance
* If a file doesn't exist, the operation is skipped (no error)
* Ignored files (`.pteroignore`) are protected and cannot be deleted
* Path traversal is prevented
* Symlinks are followed and the target is deleted

<Warning>
  **Deletion is permanent and cannot be undone.** Ensure you have backups before deleting important files or directories.
</Warning>

## Error Responses

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    Missing or invalid Bearer token
  </Accordion>

  <Accordion title="403 Forbidden">
    File is on the ignore list or path traversal attempt
  </Accordion>

  <Accordion title="404 Not Found">
    Server does not exist
  </Accordion>

  <Accordion title="500 Internal Server Error">
    Failed to delete file (permission error, file in use, etc.)
  </Accordion>
</AccordionGroup>

## Use Cases

* Clean up temporary files
* Remove old logs
* Delete unused plugins
* Clear cache directories
* Remove outdated backups
* Batch delete operations

## Source Reference

Implementation: `router/router_server_files.go` (postServerDeleteFiles function)
