> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/caches/delete-cached-responses-in-bulk/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Delete cached responses in bulk DELETE https://api.respan.ai/api/caches/bulk/ Content-Type: application/json Delete cached responses using exactly one selector: `cache_keys`, `ids`, or `all: true`. Up to 1,000 keys or IDs can be deleted per request. `ids` uses internal integer IDs and is JWT-only; API-key clients should use `cache_keys` or `all`. Rate limit: 60 requests per minute per organization for API-key calls (shared across API keys) and per user for JWT calls. Reference: https://respan.ai/docs/apis/caches/delete-cached-responses-in-bulk ## Authentication - `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan\_params.credential\_override in the request body, not in this authentication field. - `Authorization` header (bearer token, required) — Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead. ## Request ### Body (application/json) This endpoint expects an object. - `cache_keys` (list of string, optional) — Cache keys to delete. Supported for API key and JWT authentication. - `ids` (list of integer, optional) — Internal numeric cache entry IDs to delete. JWT only. - `all` (boolean, optional) — Set to true to delete all cached responses for the current organization. The server rejects false. ## Response ### 200 Cached responses were deleted synchronously. - `success_count` (integer, required) — Number of items successfully processed. - `error_count` (integer, required) — Number of items that failed. - `errors` (list of BulkItemError, required) — Item-level failures, keyed by zero-based input index. - `deleted_count` (integer, required) — Number of resources matched and processed for deletion. - `message` (string, required) — Human-readable deletion result. ## Errors ### 400 Bad Request Error The selector is invalid, more than one selector was supplied, or API-key authentication was used with `ids`. - `map from string to any` ### 403 Forbidden Error The API key is missing, invalid or expired, or it can't delete cached responses. - `detail` (string, required) ### 422 Unprocessable Entity Error The request contains more than 1,000 cache keys or IDs. - `detail` (string, required) ### 429 Too Many Requests Error Rate limit exceeded. - `detail` (string, required) - `retry_after` (integer, optional) — Seconds to wait before retrying. ## Types ### BulkItemError An item that failed during a bulk operation. `index` is zero-based and identifies the corresponding item in the request array. - `index` (integer, required) — Zero-based index of the failed item in the submitted array. - `error` (string, required) — Error message for the failed item. ## Examples ### Delete selected cache keys **Request** ```json { "all": true } ``` **Response** ```json { "success_count": 0, "error_count": 0, "errors": [], "deleted_count": 0, "message": "Successfully deleted 0 cached responses" } ``` **SDK Code** ```python Delete selected cache keys import requests url = "https://api.respan.ai/api/caches/bulk/" payload = { "all": True } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.delete(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Delete selected cache keys const url = 'https://api.respan.ai/api/caches/bulk/'; const options = { method: 'DELETE', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"all":true}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Delete selected cache keys package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/caches/bulk/" payload := strings.NewReader("{\n \"all\": true\n}") req, _ := http.NewRequest("DELETE", url, payload) req.Header.Add("Authorization", "Bearer ") 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 Delete selected cache keys require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/caches/bulk/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"all\": true\n}" response = http.request(request) puts response.read_body ``` ```java Delete selected cache keys import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.delete("https://api.respan.ai/api/caches/bulk/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"all\": true\n}") .asString(); ``` ```php Delete selected cache keys request('DELETE', 'https://api.respan.ai/api/caches/bulk/', [ 'body' => '{ "all": true }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Delete selected cache keys using RestSharp; var client = new RestClient("https://api.respan.ai/api/caches/bulk/"); var request = new RestRequest(Method.DELETE); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"all\": true\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Delete selected cache keys import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["all": true] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/caches/bulk/")! 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() ``` ### Delete all cached responses **Request** ```json { "all": true } ``` **Response** ```json { "success_count": 0, "error_count": 0, "errors": [], "deleted_count": 0, "message": "Successfully deleted 0 cached responses" } ``` **SDK Code** ```python Delete all cached responses import requests url = "https://api.respan.ai/api/caches/bulk/" payload = { "all": True } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.delete(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Delete all cached responses const url = 'https://api.respan.ai/api/caches/bulk/'; const options = { method: 'DELETE', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"all":true}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Delete all cached responses package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/caches/bulk/" payload := strings.NewReader("{\n \"all\": true\n}") req, _ := http.NewRequest("DELETE", url, payload) req.Header.Add("Authorization", "Bearer ") 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 Delete all cached responses require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/caches/bulk/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"all\": true\n}" response = http.request(request) puts response.read_body ``` ```java Delete all cached responses import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.delete("https://api.respan.ai/api/caches/bulk/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"all\": true\n}") .asString(); ``` ```php Delete all cached responses request('DELETE', 'https://api.respan.ai/api/caches/bulk/', [ 'body' => '{ "all": true }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Delete all cached responses using RestSharp; var client = new RestClient("https://api.respan.ai/api/caches/bulk/"); var request = new RestRequest(Method.DELETE); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"all\": true\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Delete all cached responses import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["all": true] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/caches/bulk/")! 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() ``` ### Delete selected internal IDs (JWT only) **Request** ```json { "all": true } ``` **Response** ```json { "success_count": 0, "error_count": 0, "errors": [], "deleted_count": 0, "message": "Successfully deleted 0 cached responses" } ``` **SDK Code** ```python Delete selected internal IDs (JWT only) import requests url = "https://api.respan.ai/api/caches/bulk/" payload = { "all": True } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.delete(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Delete selected internal IDs (JWT only) const url = 'https://api.respan.ai/api/caches/bulk/'; const options = { method: 'DELETE', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"all":true}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Delete selected internal IDs (JWT only) package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/caches/bulk/" payload := strings.NewReader("{\n \"all\": true\n}") req, _ := http.NewRequest("DELETE", url, payload) req.Header.Add("Authorization", "Bearer ") 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 Delete selected internal IDs (JWT only) require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/caches/bulk/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"all\": true\n}" response = http.request(request) puts response.read_body ``` ```java Delete selected internal IDs (JWT only) import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.delete("https://api.respan.ai/api/caches/bulk/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"all\": true\n}") .asString(); ``` ```php Delete selected internal IDs (JWT only) request('DELETE', 'https://api.respan.ai/api/caches/bulk/', [ 'body' => '{ "all": true }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Delete selected internal IDs (JWT only) using RestSharp; var client = new RestClient("https://api.respan.ai/api/caches/bulk/"); var request = new RestRequest(Method.DELETE); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"all\": true\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Delete selected internal IDs (JWT only) import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["all": true] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/caches/bulk/")! 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() ```