# Delete a mount file or folder

Delete a file, or a folder with everything inside it, from a mount.

`DELETE https://api.smallworld.sh/api/v1/mounts/:mountId/files`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| mountId | path | UUID | Yes | The mount's ID, returned as id when the mount was created. |
| path | query | string | Yes | A path inside the mount, such as /guides/refunds.md for /workspace/docs/guides/refunds.md in a mount at /workspace/docs. guides/refunds.md names the same file. No empty, . or .. segments and no trailing slash. URL-encode it. |

## Request examples

### curl

```curl
curl --fail-with-body -X DELETE 'https://api.smallworld.sh/api/v1/mounts/0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d/files?path=/guides' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY"
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/mounts/0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d/files?path=/guides", {
  method: "DELETE",
  headers: { Authorization: `Bearer ${apiKey}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
```

### python

```python
response = requests.delete(
    "https://api.smallworld.sh/api/v1/mounts/0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d/files?path=/guides",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns deleted: true after deletion succeeds.

### 200

Returns deleted: true after deletion succeeds.

```json
{
  "deleted": true
}
```

### 400

invalid_request: The path query parameter is missing or empty, or the request has another query parameter; the message names the problem. mount_invalid_path: The path query parameter isn't a canonical path inside the mount: it is / itself, ends with a slash, has empty, . or .. segments, contains null bytes, backslashes, or control characters, or is too long.

#### invalid_request

The path query parameter is missing or empty, or the request has another query parameter; the message names the problem.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "Unknown query parameter: color"
}
```

#### mount_invalid_path

The path query parameter isn't a canonical path inside the mount: it is / itself, ends with a slash, has empty, . or .. segments, contains null bytes, backslashes, or control characters, or is too long.

```json
{
  "statusCode": 400,
  "code": "mount_invalid_path",
  "message": "path must be a canonical path, without empty, . or .. segments or a trailing slash"
}
```

### 401

authentication_required: The Authorization header is missing or empty. invalid_api_key: The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

#### authentication_required

The Authorization header is missing or empty.

```json
{
  "statusCode": 401,
  "code": "authentication_required",
  "message": "Authentication is required"
}
```

#### invalid_api_key

The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

```json
{
  "statusCode": 401,
  "code": "invalid_api_key",
  "message": "The API key is invalid or revoked"
}
```

### 403

ip_not_allowed: The request came from an address outside the workspace's IP allowlist.

#### ip_not_allowed

The request came from an address outside the workspace's IP allowlist.

```json
{
  "statusCode": 403,
  "code": "ip_not_allowed",
  "message": "The source IP address is not allowed by this account's security settings"
}
```

### 404

mount_not_found: The mount does not exist in your workspace, or mountId isn't a mount ID. mount_file_not_found: The mount has no file or folder at this path. The message names the path as the terminal sees it.

#### mount_not_found

The mount does not exist in your workspace, or mountId isn't a mount ID.

```json
{
  "statusCode": 404,
  "code": "mount_not_found",
  "message": "Mount not found"
}
```

#### mount_file_not_found

The mount has no file or folder at this path. The message names the path as the terminal sees it.

```json
{
  "statusCode": 404,
  "code": "mount_file_not_found",
  "message": "No file or folder at /workspace/docs/guides"
}
```

### 500

internal_error: An unexpected server error.

#### internal_error

An unexpected server error.

```json
{
  "statusCode": 500,
  "code": "internal_error",
  "message": "Internal server error"
}
```

## Notes

- This delete is direct: it skips the mount's settings, tool call hooks, and approvals, and takes effect at once. It appears in the mount's change log in the dashboard. Smallworld keeps no history of mount files, so it can't be undone.

- A command that first saw something at this path before your delete and changes it, also one waiting for approval, has its changes to the mount discarded, with a notice in stderr.
