> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hopx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove File

> Delete a file or directory from the sandbox using the HopX VM Agent API. Remove files or directories to clean up sandbox filesystem, free disk space, and manage storage. Learn how to use DELETE /files/remove endpoint to delete files or directories recursively. Includes request examples and cleanup best practices.

Delete a file or directory. Directories are removed recursively.

## Endpoint

```
DELETE /files/remove
```

## Request

### Headers

```
Authorization: Bearer YOUR_JWT_TOKEN
```

### Query Parameters

| Parameter | Type   | Required | Description    |
| --------- | ------ | -------- | -------------- |
| `path`    | string | Yes      | Path to delete |

### Example Request

```bash theme={null}
curl -X DELETE "https://sandbox_abc123xyz.hopx.dev/files/remove?path=/workspace/old_data.txt" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
```

## Response

### Success (200 OK)

```json theme={null}
{
  "message": "File deleted successfully",
  "path": "/workspace/old_data.txt"
}
```

## Status Codes

| Code | Description    |
| ---- | -------------- |
| 200  | Deleted        |
| 401  | Unauthorized   |
| 404  | File not found |

## Use Cases

### Cleanup Old Files

```bash theme={null}
curl -X DELETE "https://sandbox_abc123xyz.hopx.dev/files/remove?path=/workspace/temp.txt" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
```

### Remove Directory

```bash theme={null}
curl -X DELETE "https://sandbox_abc123xyz.hopx.dev/files/remove?path=/workspace/old_project" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
```

## Related

* **SDK**: [sandbox.files.remove()](/sdk/python/files#remove) - Python SDK method
* [CLI File Operations](/cli/commands/files) - File operations from CLI

## Next Steps

* **[List Files](/api/vm-agent/list-files)** - Browse files
* **[Write File](/api/vm-agent/write-file)** - Create new files
