How to Delete All Jobs Using the REST API

Run the following commands to delete all jobs in an Azure Databricks workspace.

  1. Identify the jobs to delete and list them in a text file:

    curl -X GET -u "Bearer: <token>" https://<databricks-instance>/api/2.0/jobs/list | grep -o -P 'job_id.{0,6}' | awk -F':' '{print $2}' >> job_id.txt
    
  2. Run the `curl` command in a loop to delete the identified jobs:

    while read line
    do
    job_id=$line
    curl -X POST -u "Bearer: <token>" https://<databricks-instance>/api/2.0/jobs/delete -d '{"job_id": '"$job_id"'}'
    done < job_id.txt