Delete Run API
Delete an async job and its data
Delete an async job and all associated data. This operation is permanent.
job_id
stringThe unique job identifier (e.g., run_abc123).
Response
Returns 204 No Content on successful deletion.
curl -X DELETE http://127.0.0.1:8005/api/v1/runs/run_abc123import 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")# 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(empty response body){
"detail": "Cannot delete running job. Cancel it first."
}{
"detail": "Job not found: run_abc123"
}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
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 |