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

# Delete Directory

> Delete a directory. Pass recursive=true to remove non-empty directories.

## Overview

Removes a directory from the session workspace. By default the directory must be empty — pass `recursive=true` to remove a non-empty tree. To remove a single file, use `DELETE /fs/file` instead.

## Path Parameters

<ParamField path="id" type="string" required={true}>
  Browser session ID (UUID).
</ParamField>

## Query Parameters

<ParamField query="path" type="string" required={true}>
  Workspace-relative directory path to delete.
</ParamField>

<ParamField query="recursive" type="boolean" default="false">
  When `true`, delete the directory and all its contents. When `false`, the call fails with `409` if the directory is non-empty.
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL (empty dir) theme={null}
  curl -X DELETE -G "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/dir" \
    -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
    --data-urlencode "path=exports/csv"
  ```

  ```bash cURL (recursive) theme={null}
  curl -X DELETE -G "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/dir" \
    -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
    --data-urlencode "path=exports" \
    --data-urlencode "recursive=true"
  ```
</CodeGroup>

## Response

### Success Response (204)

No content.

### Error Responses

| Status | Description                                                                                 |
| ------ | ------------------------------------------------------------------------------------------- |
| `400`  | Invalid path.                                                                               |
| `401`  | Unauthorized — invalid or missing API key.                                                  |
| `404`  | Session or directory not found.                                                             |
| `409`  | Directory is not empty and `recursive` was not set, or target is not a directory (ENOTDIR). |
