> 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 run

DELETE https://aihub.instabase.com/api/v2/apps/runs/{run_id}

Deletes a specified automation app run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion](/api-sdk/api-reference/jobs/job-status).Deleting the run's input files also deletes the batch that the run processed.

Reference: https://docs.instabase.com/api-sdk/api-reference/runs/delete-run

## Authentication

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

## Request

### Path parameters

- `run_id` (string, required) — The run ID.

### Query parameters

- `delete_db_data` (boolean, optional, default: true) — Delete the run's database data.
- `delete_input` (boolean, optional, default: true) — Delete the run's input files.
- `delete_output` (boolean, optional, default: true) — Delete the run's output files.
- `delete_logs` (boolean, optional, default: true) — Delete the run's logs.

### Headers

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

## Response

### 202

Run deletion request accepted. The response contains a job ID for each file deletion that started, so a key is absent if you set its corresponding option to `false`. [Poll each job ID](/api-sdk/api-reference/jobs/job-status) to check completion status.

- `delete_input_dir_job_id` (string, optional) — Job ID for deleting the input directory. Returned only when `delete_input` is `true` and the deletion job started.
- `delete_output_dir_job_id` (string, optional) — Job ID for deleting the output directory. Returned only when `delete_output` is `true` and the deletion job started.
- `delete_log_dir_job_id` (string, optional) — Job ID for deleting the log directory. Returned only when `delete_logs` is `true` and the deletion job started.

## Examples

**Response**

```json
{
  "delete_input_dir_job_id": "string",
  "delete_output_dir_job_id": "string",
  "delete_log_dir_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"
)

response = client.apps.runs.delete(
    run_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890"
)

# a job ID is returned only for the files that are deleted
job_ids = [
    job_id for job_id in [
        response.delete_input_dir_job_id,
        response.delete_output_dir_job_id,
        response.delete_log_dir_job_id
    ] if job_id
]

# poll each job until it reaches a terminal state
while job_ids:
    for job_id in job_ids[:]:
        state = client.jobs.status(job_id).state
        if state in ["COMPLETE", "FAILED", "CANCELLED"]:
            job_ids.remove(job_id)
            if state != "COMPLETE":
                print(f"Job {job_id} ended in state {state}")
    if job_ids:
        time.sleep(5)  # pause before polling again

```

```python without SDK
import requests

run_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
url = f"https://aihub.instabase.com/api/v2/apps/runs/{run_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("Run deletion request accepted")
    # a job ID is returned only for the files that are deleted
    job_ids = response.json()
    for key in ["delete_input_dir_job_id",
                "delete_output_dir_job_id",
                "delete_log_dir_job_id"]:
        if key in job_ids:
            print(f"{key}: {job_ids[key]}")
else:
    print(f"Error: {response.status_code} - {response.text}")

# not included here: poll each job ID until it's done

```

```javascript
const url = 'https://aihub.instabase.com/api/v2/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890';
const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};

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/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890"

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

	req.Header.Add("Authorization", "Bearer <token>")

	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/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890")

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

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'

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/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://aihub.instabase.com/api/v2/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://aihub.instabase.com/api/v2/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://aihub.instabase.com/api/v2/apps/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890")! 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()
```