Databricks

Databricks Jobs API: Job Automation, CI/CD, and Monitoring

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Databricks jobs can be managed by hand in the UI, but understanding the Jobs API is essential for production operations and CI/CD pipelines. This article walks through Jobs API 2.1's endpoint layout, request examples, job-definition JSON structure, authentication methods, and execution monitoring with the Runs API in a single, structured guide.

Jobs API 2.1 Endpoint Reference

The main endpoints used in Jobs API 2.1 are listed below. The base URL for every endpoint is https://<workspace-url>/api/2.1/jobs/.

OperationMethodEndpointPurpose
Create jobPOST/api/2.1/jobs/createDefine and register a new job
List jobsGET/api/2.1/jobs/listFetch all jobs in the workspace
Get jobGET/api/2.1/jobs/get?job_id={id}Fetch the definition and state of a specific job
Run nowPOST/api/2.1/jobs/run-nowTrigger an existing job
Reset jobPOST/api/2.1/jobs/resetFully overwrite the job definition
Partial updatePOST/api/2.1/jobs/updateChange only specific fields of the job definition
Delete jobPOST/api/2.1/jobs/deletePermanently delete the job
List runsGET/api/2.1/jobs/runs/listFetch the job's run history
Get runGET/api/2.1/jobs/runs/get?run_id={id}Fetch the state and result of a specific run
Cancel runPOST/api/2.1/jobs/runs/cancelStop a running run

reset replaces the entire job definition (unspecified fields revert to defaults), whereasupdate only changes the fields you specify. CI/CD workflows manage the full definition in code, so reset is used heavily there.

curl Request Examples

Below are curl examples that create and then run a job using a PAT.

# Create job
curl -X POST \
  https://adb-1234567890.12.azuredatabricks.net/api/2.1/jobs/create \
  -H "Authorization: Bearer dapi_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "daily_etl_pipeline",
    "tasks": [{
      "task_key": "ingest",
      "notebook_task": {
        "notebook_path": "/Repos/prod/etl/ingest"
      },
      "new_cluster": {
        "spark_version": "14.3.x-scala2.12",
        "node_type_id": "i3.xlarge",
        "num_workers": 4
      }
    }]
  }'

# Run job (run-now)
curl -X POST \
  https://adb-1234567890.12.azuredatabricks.net/api/2.1/jobs/run-now \
  -H "Authorization: Bearer dapi_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"job_id": 12345}'

Python Request Example

The same flow using the requests library. In production, add proper error handling and retry logic.

import requests

WORKSPACE_URL = "https://adb-1234567890.12.azuredatabricks.net"
TOKEN = "dapi_xxxxxxxxxxxx"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}

# Create job
job_config = {
    "name": "daily_etl_pipeline",
    "tasks": [{
        "task_key": "ingest",
        "notebook_task": {"notebook_path": "/Repos/prod/etl/ingest"},
        "new_cluster": {
            "spark_version": "14.3.x-scala2.12",
            "node_type_id": "i3.xlarge",
            "num_workers": 4
        }
    }]
}
resp = requests.post(
    f"{WORKSPACE_URL}/api/2.1/jobs/create",
    headers=HEADERS, json=job_config
)
job_id = resp.json()["job_id"]

# Run now
run_resp = requests.post(
    f"{WORKSPACE_URL}/api/2.1/jobs/run-now",
    headers=HEADERS, json={"job_id": job_id}
)
run_id = run_resp.json()["run_id"]

# Poll for run result
import time
while True:
    status = requests.get(
        f"{WORKSPACE_URL}/api/2.1/jobs/runs/get",
        headers=HEADERS, params={"run_id": run_id}
    ).json()
    life_cycle = status["state"]["life_cycle_state"]
    if life_cycle in ("TERMINATED", "INTERNAL_ERROR", "SKIPPED"):
        break
    time.sleep(30)

Job Definition JSON Structure (Multi-Task)

The headline feature of Jobs API 2.1 is multi-task jobs. You can define multiple tasks inside a single job and declare dependencies between them with depends_on.

{
  "name": "daily_pipeline",
  "schedule": {
    "quartz_cron_expression": "0 0 6 * * ?",
    "timezone_id": "Asia/Tokyo"
  },
  "tasks": [
    {
      "task_key": "extract",
      "notebook_task": {"notebook_path": "/Repos/prod/etl/extract"},
      "new_cluster": { ... }
    },
    {
      "task_key": "transform",
      "depends_on": [{"task_key": "extract"}],
      "notebook_task": {"notebook_path": "/Repos/prod/etl/transform"},
      "new_cluster": { ... }
    },
    {
      "task_key": "load",
      "depends_on": [{"task_key": "transform"}],
      "notebook_task": {"notebook_path": "/Repos/prod/etl/load"},
      "new_cluster": { ... }
    }
  ],
  "email_notifications": {
    "on_failure": ["[email protected]"]
  },
  "max_concurrent_runs": 1
}

Setting max_concurrent_runs to 1 prevents the next run from starting until the previous one completes. Setting it to 1 is standard for production jobs to avoid collisions between scheduled triggers and the run-now API.

Passing Parameters

You can pass parameters dynamically when triggering a job with the run-now API. For notebook tasks, values flow through base_parameters (defaults defined in the job) and notebook_params (overrides supplied at run-now time).

# Override parameters at run-now
curl -X POST .../api/2.1/jobs/run-now \
  -d '{
    "job_id": 12345,
    "notebook_params": {
      "target_date": "2026-03-27",
      "mode": "full_refresh"
    }
  }'

Inside the notebook, read parameters with dbutils.widgets.get("target_date"). For Python tasks use python_params, and for SparkSubmit tasks use spark_submit_params.

Monitoring Runs with the Runs API

Use the Runs API to inspect job execution results. The most important fields are listed below.

FieldExample valueMeaning
life_cycle_statePENDING / RUNNING / TERMINATEDLifecycle stage of the run
result_stateSUCCESS / FAILED / TIMEDOUT / CANCELEDFinal result on completion (only when TERMINATED)
state_message"Cluster is starting..."Current status message
start_time1711526400000Start time (epoch milliseconds)
end_time1711530000000End time (epoch milliseconds)

Comparing API Authentication Methods

Auth methodUse caseExpirationRecommended scenario
PAT (Personal Access Token)Individual development and testingSet manually (up to 365 days)Local development and one-off scripts
OAuth M2M (Service Principal)CI/CD and automationAutomatic rotationPipelines such as GitHub Actions and Azure DevOps
Azure AAD TokenAzure integrationShort-lived (1 hour)Calls from Azure-managed environments

What the Exam Tests

  • "reset vs. update" → reset overwrites the entire definition; update changes only specific fields
  • "run-now vs. submit" → run-now runs an existing job; submit (runs/submit) runs an ephemeral job definition immediately
  • "Purpose of max_concurrent_runs" → caps concurrent runs of the same job to prevent resource contention and data inconsistency
  • "Best auth for CI/CD pipelines" → OAuth M2M (Service Principal)

Check with a Sample Question

Data Engineer Professional

問題 1

A data engineering team is building a CI/CD pipeline that automatically deploys and runs jobs through the Databricks Jobs API from GitHub Actions. They want to eliminate the risk of API access being revoked when a team member leaves. Which authentication method is most appropriate?

  1. Share the team lead's Personal Access Token (PAT)
  2. Create a Service Principal and obtain tokens via OAuth M2M authentication
  3. Use the workspace admin's username and password with Basic authentication
  4. Have each member issue an individual PAT and register them separately in GitHub Secrets

正解: B

OAuth M2M authentication backed by a Service Principal is not tied to a specific user, so it is unaffected by departures or transfers. Sharing a PAT is a serious security risk, and Basic authentication is not supported by Databricks. Registering individual PATs per member means you must revoke tokens whenever someone leaves, which increases operational overhead.

Frequently Asked Questions

What's the difference between Jobs API 2.0 and 2.1?

Jobs API 2.1 added support for multi-task jobs (a single job definition can contain multiple tasks with declared dependencies). In 2.0, each job was a single task, but in 2.1 you define multiple tasks as an array in the tasks field and control execution order with depends_on. Version 2.1 is recommended for all new development.

Should I use PAT or OAuth M2M to create jobs with the Jobs API?

For CI/CD pipelines and automation scripts, OAuth M2M (Machine-to-Machine) authentication is the recommended approach. PATs require manual expiration management and are tied to a user, which creates risk when that person leaves or transfers. OAuth M2M is bound to a Service Principal and supports automatic token rotation, so M2M is the right fit for production operations.

Are jobs created via the Jobs API different from jobs created in the UI?

There is no functional difference. Jobs created in the UI can be fetched, edited, and run via the API, and jobs created via the API can be viewed and manually triggered from the UI. That said, when you manage jobs through CI/CD, the recommended practice is to create them via the API or Databricks Asset Bundles (DABs) and prohibit manual edits in the UI.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Databricks

Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)

Complete guide to all 7 Databricks certifications — Data Eng...

Databricks

Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)

Every Databricks certification ranked by difficulty, with st...

Databricks

Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)

How to pass Databricks certifications efficiently. Official ...

Databricks

Databricks Data Engineer Associate: Complete Guide (2026)

Domain-by-domain breakdown of the Databricks Certified Data ...

Databricks

Databricks Data Engineer Professional: Complete Guide (2026)

Tactics for the Databricks Certified Data Engineer Professio...

Browse all Databricks articles (110)
© 2026 NicheeLab All rights reserved.