> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.privategpt.dev/api-reference/files/delete-by-prefix-v-1-files-delete/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server. # Delete all files matching a prefix (bulk delete) DELETE /v1/files S3/blob-style bulk delete: remove every uploaded file whose key starts with *prefix* (e.g. `data/2024/` deletes all files in that virtual folder). Only upload-side files are affected; sandbox output files cannot be bulk-deleted. Returns the count of files actually removed. Anthropic SDK callers can reach this via `client.beta.files.with_raw_response` or a plain `httpx` call with `extra_query={...prefix: data/2024/...}`. Reference: https://docs.privategpt.dev/api-reference/files/delete-by-prefix-v-1-files-delete ## Request ### Query parameters - `scope_id` (string, required) — Session / container identifier. - `prefix` (string, required) — Key prefix to delete. All uploaded files whose relative path starts with this string are removed. Must be non-empty. A trailing `/` is recommended to avoid accidentally deleting sibling keys that share the same prefix string (e.g. use `data/2024/` not `data/2024`). - `namespace` (string, optional, default: session) — Namespace to delete from. Defaults to 'session'. ## Response ### 200 Successful Response - `prefix` (string, required) — The key prefix that was deleted. - `deleted_count` (integer, required) — Number of files actually removed. - `type` ("prefix_deleted", optional, default: prefix_deleted) — Object type discriminator, always 'prefix_deleted'. ## Errors ### 400 Bad Request Error prefix is missing or empty. - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) — detail field. ### 503 Service Unavailable Error Files API not configured. - `any` ## Types ### ValidationError ValidationError schema. - `loc` (list of ValidationErrorLocItems, required) — loc field. - `msg` (string, required) — msg field. - `type` (string, required) — type field. - `input` (any, optional) — input field. - `ctx` (ValidationErrorCtx, optional) — ctx field. ### ValidationErrorLocItems ### ValidationErrorCtx ctx field. ## Examples **Response** ```json { "prefix": "data/2024/", "deleted_count": 3, "type": "prefix_deleted" } ``` **SDK Code** ```python import requests url = "https://api.example.com/v1/files" querystring = {"prefix":"prefix","scope_id":"scope_id"} response = requests.delete(url, params=querystring) print(response.json()) ``` ```javascript const url = 'https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id'; const options = {method: 'DELETE'}; 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" "net/http" "io" ) func main() { url := "https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id" req, _ := http.NewRequest("DELETE", url, nil) 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://api.example.com/v1/files?prefix=prefix&scope_id=scope_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.delete("https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id") .asString(); ``` ```php request('DELETE', 'https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id'); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id"); var request = new RestRequest(Method.DELETE); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/files?prefix=prefix&scope_id=scope_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "DELETE" 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() ```