> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.instabase.com/api-sdk/api-reference/batches/delete-batch/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server. # Delete batch DELETE https://aihub.instabase.com/api/v2/batches/{batch_id} Delete a batch and all its files. This is an asynchronous operation that must be [checked for completion](/api-sdk/api-reference/jobs/job-status). Reference: https://docs.instabase.com/api-sdk/api-reference/batches/delete-batch ## Authentication - `Authorization` header (bearer token, required) — Bearer HTTP authentication. ## Request ### Path parameters - `batch_id` (integer, required) — The batch ID. ### Headers - `IB-Context` (string, optional) — Typically your organization ID. See [Authorization and context identification](/api-sdk/authorization#ib-context-header) for details. ## Response ### 202 Batch deletion request accepted. [Poll the job ID](/api-sdk/api-reference/jobs/job-status) to check completion status. - `job_id` (string, required) — The job ID of the operation. Use the job ID with the [poll file operation job status](/api-sdk/api-reference/jobs/job-status) endpoint to check batch deletion status. ## Errors ### 404 Not Found Error Batch does not exist. - `any` ## Examples **Response** ```json { "job_id": "string" } ``` **SDK Code** ```python with SDK import time from aihub import AIHub client = AIHub( api_root="https://aihub.instabase.com/api", api_key="abcdefghijklmnopqrst1234567890", ib_context="john.doe_acme.com" ) delete_response = client.batches.delete(batch_id=12345) # poll the job until it reaches a terminal state while True: status_response = client.jobs.status( job_id=delete_response.job_id ) if status_response.state not in ["PENDING", "RUNNING"]: break time.sleep(3) # pause before polling the status again if status_response.state != "COMPLETE": print(f"Deletion ended in state {status_response.state}") ``` ```python without SDK import requests batch_id = 12345 url = f"https://aihub.instabase.com/api/v2/batches/{batch_id}" 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("Batch deletion job started with ID: " f"{response.json()['job_id']}") else: print(f"Error: {response.status_code} - {response.text}") # not included here: check status of deletion job until it's done ``` ```javascript const url = 'https://aihub.instabase.com/api/v2/batches/12345'; const options = {method: 'DELETE', headers: {Authorization: 'Bearer '}}; 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://aihub.instabase.com/api/v2/batches/12345" req, _ := http.NewRequest("DELETE", url, nil) req.Header.Add("Authorization", "Bearer ") 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/batches/12345") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request["Authorization"] = 'Bearer ' 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://aihub.instabase.com/api/v2/batches/12345") .header("Authorization", "Bearer ") .asString(); ``` ```php request('DELETE', 'https://aihub.instabase.com/api/v2/batches/12345', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://aihub.instabase.com/api/v2/batches/12345"); var request = new RestRequest(Method.DELETE); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/batches/12345")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "DELETE" request.allHTTPHeaderFields = headers 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() ```