> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.instabase.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server.

# Delete file or folder

DELETE https://aihub.instabase.com/api/v2/files/{path}

Delete a single file or folder.This operation is also available via the SDK method `client.files.delete()`.This acts on files in the AI Hub filesystem, not your local filesystem.Ensure the path is accessible within the context defined by the `IB-Context` header.Not all filesystem types support this operation.| Filesystem           | Supported |
| -------------------- | --------- |
| Instabase            | ✓         |
| Amazon S3            | ✓         |
| Azure Blob Storage   | ✓         |
| Google Cloud Storage | ✓         |
| Google Drive         | -         |

Reference: https://docs.instabase.com/api-sdk/api-reference/files/delete-file-or-folder

## Authentication

- `Authorization` header (bearer token, required) — Bearer HTTP authentication.

## Request

### Path parameters

- `path` (string, required) — Full path to the file or folder.

### Headers

- `IB-Context` (string, optional) — Typically your organization ID. See [Authorization and context identification](/api-sdk/authorization#ib-context-header) for details.

## Response

### 202

Indicates that the deletion request has been accepted. The operation returns this status code regardless of whether the file or folder exists.

## Examples

**Request**

```json
{}
```

**Response**

```json
{}
```

**SDK Code**

```python Delete file with SDK
from aihub import AIHub

client = AIHub(
    api_root="https://aihub.instabase.com/api",
    api_key="abcdefghijklmnopqrst1234567890",
    ib_context="john.doe_acme.com"
)

organization_id = "acme_org"
workspace = "MyWorkspace"
drive = "Instabase Drive"
folder = "my-folder"
file_name = "hello.txt"
file_path = f"{organization_id}/{workspace}/fs/{drive}/{folder}/{file_name}"

# returns None
client.files.delete(path=file_path)

```

```python Delete file without SDK
import requests

organization_id = "acme_org"
workspace = "MyWorkspace"
drive = "Instabase Drive"
folder = "my-folder"
file_name = "hello.txt"
file_path = f"{organization_id}/{workspace}/fs/{drive}/{folder}/{file_name}"

url = f"https://aihub.instabase.com/api/v2/files/{file_path}"

headers = {
    "Authorization": "Bearer abcdefghijklmnopqrst1234567890",
    "IB-Context": "john.doe_acme.com"
}

# make the DELETE request
response = requests.delete(url, headers=headers)

# handle the response
if response.status_code == 202:
    print("File deletion request accepted")
else:
    print(f"Error: {response.status_code} - {response.text}")

```

```python Delete folder with SDK
from aihub import AIHub

client = AIHub(
    api_root="https://aihub.instabase.com/api",
    api_key="abcdefghijklmnopqrst1234567890",
    ib_context="john.doe_acme.com"
)

organization_id = "acme_org"
workspace = "MyWorkspace"
drive = "Instabase Drive"
folder = "MyFolder"
folder_path = f"{organization_id}/{workspace}/fs/{drive}/{folder}"

# returns None
client.files.delete(path=folder_path)

```

```python Delete folder without SDK
import requests

organization_id = "acme_org"
workspace = "MyWorkspace"
drive = "Instabase Drive"
folder = "MyFolder"
folder_path = f"{organization_id}/{workspace}/fs/{drive}/{folder}"

url = f"https://aihub.instabase.com/api/v2/files/{folder_path}"

headers = {
    "Authorization": "Bearer abcdefghijklmnopqrst1234567890",
    "IB-Context": "john.doe_acme.com"
}

# make the DELETE request
response = requests.delete(url, headers=headers)

# handle the response
if response.status_code == 202:
    print("Folder deletion request accepted")
else:
    print(f"Error: {response.status_code} - {response.text}")

```

```javascript
const url = 'https://aihub.instabase.com/api/v2/files/path';
const options = {
  method: 'DELETE',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://aihub.instabase.com/api/v2/files/path"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("DELETE", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://aihub.instabase.com/api/v2/files/path")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://aihub.instabase.com/api/v2/files/path")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://aihub.instabase.com/api/v2/files/path', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/files/path");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/files/path")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```