zg
New Contributor III

You're absolutely right! Even though I had tried it before, it didn’t work initially. However, I resolved the problem by reviewing the API's structure using the UI. By following the same structure and defining a new alert condition, it worked without any errors. Here's the code I used:

import requests
import json

# Databricks API Details
HOST = "https://<databricks-workspace>.azuredatabricks.net"
TOKEN = "token"
ENDPOINT = f"{HOST}/api/2.0/sql/alerts"

# Function to check the alert API
def check_alert_api():
headers = {
"Authorization": f"Bearer {TOKEN}"
}
response = requests.get(ENDPOINT, headers=headers)
print("Response Data:", json.dumps(response.json(), indent=4))

# Execute the function
check_alert_api()

View solution in original post