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.
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/.
| Operation | Method | Endpoint | Purpose |
|---|---|---|---|
| Create job | POST | /api/2.1/jobs/create | Define and register a new job |
| List jobs | GET | /api/2.1/jobs/list | Fetch all jobs in the workspace |
| Get job | GET | /api/2.1/jobs/get?job_id={id} | Fetch the definition and state of a specific job |
| Run now | POST | /api/2.1/jobs/run-now | Trigger an existing job |
| Reset job | POST | /api/2.1/jobs/reset | Fully overwrite the job definition |
| Partial update | POST | /api/2.1/jobs/update | Change only specific fields of the job definition |
| Delete job | POST | /api/2.1/jobs/delete | Permanently delete the job |
| List runs | GET | /api/2.1/jobs/runs/list | Fetch the job's run history |
| Get run | GET | /api/2.1/jobs/runs/get?run_id={id} | Fetch the state and result of a specific run |
| Cancel run | POST | /api/2.1/jobs/runs/cancel | Stop 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.
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}'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)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.
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.
Use the Runs API to inspect job execution results. The most important fields are listed below.
| Field | Example value | Meaning |
|---|---|---|
| life_cycle_state | PENDING / RUNNING / TERMINATED | Lifecycle stage of the run |
| result_state | SUCCESS / FAILED / TIMEDOUT / CANCELED | Final result on completion (only when TERMINATED) |
| state_message | "Cluster is starting..." | Current status message |
| start_time | 1711526400000 | Start time (epoch milliseconds) |
| end_time | 1711530000000 | End time (epoch milliseconds) |
| Auth method | Use case | Expiration | Recommended scenario |
|---|---|---|---|
| PAT (Personal Access Token) | Individual development and testing | Set manually (up to 365 days) | Local development and one-off scripts |
| OAuth M2M (Service Principal) | CI/CD and automation | Automatic rotation | Pipelines such as GitHub Actions and Azure DevOps |
| Azure AAD Token | Azure integration | Short-lived (1 hour) | Calls from Azure-managed environments |
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?
正解: 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.
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.
Practice with certification-focused question sets
無料で問題を解いてみる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.
Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)
Complete guide to all 7 Databricks certifications — Data Eng...
Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)
Every Databricks certification ranked by difficulty, with st...
Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)
How to pass Databricks certifications efficiently. Official ...
Databricks Data Engineer Associate: Complete Guide (2026)
Domain-by-domain breakdown of the Databricks Certified Data ...
Databricks Data Engineer Professional: Complete Guide (2026)
Tactics for the Databricks Certified Data Engineer Professio...