> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Run API

> Delete an async job and its data

Delete an async job and all associated data. This operation is permanent.

<ParamField path="job_id" type="string" required>
  The unique job identifier (e.g., `run_abc123`).
</ParamField>

## Response

Returns `204 No Content` on successful deletion.

<RequestExample>
  ```bash cURL theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  curl -X DELETE http://127.0.0.1:8005/api/v1/runs/run_abc123
  ```

  ```python Python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  import httpx

  job_id = "run_abc123"

  response = httpx.delete(f"http://127.0.0.1:8005/api/v1/runs/{job_id}")

  if response.status_code == 204:
      print(f"Job {job_id} deleted successfully")
  elif response.status_code == 404:
      print("Job not found")
  elif response.status_code == 400:
      print("Cannot delete running job")
  ```

  ```bash CLI theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Note: CLI may not have delete command; use curl or Python
  curl -X DELETE http://127.0.0.1:8005/api/v1/runs/run_abc123
  ```
</RequestExample>

<ResponseExample>
  ```text 204 No Content theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  (empty response body)
  ```

  ```json 400 Bad Request (Job Running) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "detail": "Cannot delete running job. Cancel it first."
  }
  ```

  ```json 404 Not Found theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "detail": "Job not found: run_abc123"
  }
  ```
</ResponseExample>

## Deletion Behavior

* **Completed jobs**: Can be deleted immediately
* **Cancelled jobs**: Can be deleted immediately
* **Running jobs**: Must be cancelled first before deletion
* **Queued jobs**: Must be cancelled first before deletion

## Example: Cancel and Delete

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import httpx

API_URL = "http://127.0.0.1:8005"

def force_delete_job(job_id):
    # First, try to cancel if running
    status = httpx.get(f"{API_URL}/api/v1/runs/{job_id}").json()
    
    if status["status"] in ("queued", "running"):
        print(f"Cancelling job {job_id}...")
        httpx.post(f"{API_URL}/api/v1/runs/{job_id}/cancel")
    
    # Now delete
    response = httpx.delete(f"{API_URL}/api/v1/runs/{job_id}")
    
    if response.status_code == 204:
        print(f"Job {job_id} deleted successfully")
        return True
    else:
        print(f"Failed to delete: {response.json()}")
        return False

force_delete_job("run_abc123")
```

## Error Responses

| Status | Description                      |
| ------ | -------------------------------- |
| `400`  | Cannot delete running/queued job |
| `404`  | Job not found                    |
| `500`  | Internal server error            |

## See Also

* [Cancel Run](/docs/api/praisonai/async-jobs/cancel-run)
* [List Runs](/docs/api/praisonai/async-jobs/list-runs)
* [Async Jobs Overview](/docs/api/praisonai/async-jobs)
