Friday
I'm trying to manage a scheduled AI/BI dashboard email entirely through Terraform and the API. The goal is to send a monthly PDF snapshot of the dashboard, with specific filter values already applied, to a list of subscribers and specified attachments.
What I found:
The Lakeview API create subscription lets me add subscribers to a dashboard schedule. As far as I can tell, subscribers are all it exposes. I don't see a way to choose which filter values or parameters are included in the emailed snapshot.
Jobs API. Create job has a dashboard_task that takes dashboard_id, warehouse_id, subscription and filters. The Terraform provider exposes the same fields. So a job can refresh the dashboard, apply filters and notify subscribers.Is there a way to define custom attachments declaratively via the API/Terraform?
yesterday
Hi @yanchr, you've read the APIs right. The Lakeview schedule and subscription endpoints only cover the cron, the warehouse and who gets the email. There's no field there for filter values or attachments.
The dashboard task in Lakeflow Jobs is the place to do this, and it now covers attachments too. In the Jobs API, dashboard_task.subscription has an attachment object (still marked Beta) with two parts:
Filters go in dashboard_task.filters, keyed by each filter widget's URL identifier. Here's roughly what a monthly job looks like as a Jobs API payload:
{
"name": "monthly-sales-snapshot",
"schedule": {
"quartz_cron_expression": "0 0 7 1 * ?",
"timezone_id": "Europe/London"
},
"tasks": [
{
"task_key": "send_snapshot",
"dashboard_task": {
"dashboard_id": "<dashboard-id>",
"warehouse_id": "<warehouse-id>",
"filters": {
"region": "EMEA",
"product_line": "[\"Hardware\",\"Services\"]"
},
"subscription": {
"custom_subject": "Monthly sales snapshot (EMEA)",
"subscribers": [
{ "user_name": "someone@yourcompany.com" },
{ "destination_id": "<email-destination-id>" }
],
"attachment": {
"page_attachment": {
"page_selection": "PAGE_SELECTION_SUBSET",
"page_ids": ["overview", "regional_detail"]
},
"data_attachment": {
"widgets": [
{ "page_id": "regional_detail", "widget_id": "sales_by_country" }
],
"file_format": "FILE_FORMAT_EXCEL",
"include_applied_filters": true
}
}
}
}
}
]
}A few things that are easy to miss:
For Terraform: Declarative Automation Bundles already accept the attachment block in the dashboard task schema. The Terraform databricks_job resource generates its schema from the Go SDK, which has the field, but the provider docs don't mention it yet. Before relying on it, I'd upgrade to a recent provider and run terraform providers schema -json | grep page_attachment to confirm. If it isn't there in your version, you can keep the job in a bundle, or manage it with the Jobs API from your pipeline until the provider catches up.
Docs: dashboard task for jobs (https://docs.databricks.com/aws/en/jobs/dashboard) and the Jobs create API (https://docs.databricks.com/api/workspace/jobs/create), see dashboard_task.subscription.attachment.
Hope this saves you some digging. If it works for you, marking it as the solution helps the next person find it.
yesterday
I validated this using Lakeflow Jobs Dashboard tasks, the Jobs REST API and the Databricks Terraform provider. Here are the options I have tried and the findings:
Option A : Configure through UI
The Dashboard task UI provides attachment configuration directly.
Navigate to Jobs & Pipelines โ Job โ Tasks โ Dashboard task.
You can configure:
What I validated:
Using an existing dashboard task, I verified that the UI exposes Include pages and Include data, with page/widget selection and CSV, TSV, and Excel format options.
The UI also correctly displayed attachment settings previously configured through the Jobs API.
Option B : Configure through Databricks Asset Bundles (YAML)
The equivalent bundle configuration is:
resources:
jobs:
dashboard_email_job:
name: dashboard-email-with-attachments
tasks:
- task_key: dashboard_snapshot
dashboard_task:
dashboard_id: ${var.dashboard_id}
warehouse_id: ${var.warehouse_id}
subscription:
subscribers:
- user_name: user@example.com
attachment:
data_attachment:
widgets:
- page_id: page_99999
widget_id: bar_99999
file_format: FILE_FORMAT_CSVMention that FILE_FORMAT_EXCEL and FILE_FORMAT_TSV are alternative values.
For programmatic config, the Jobs API supports attachments under: dashboard_task.subscription.attachment
Here's a minimal example:
{
"name": "dashboard-email-with-attachments",
"tasks": [
{
"task_key": "send_dashboard",
"dashboard_task": {
"dashboard_id": "YOUR_DASHBOARD_ID",
"warehouse_id": "YOUR_WAREHOUSE_ID",
"subscription": {
"paused": false,
"subscribers": [
{
"user_name": "user@example.com"
}
],
"attachment": {
"page_attachment": {
"page_selection": "PAGE_SELECTION_SUBSET",
"page_ids": ["YOUR_PAGE_ID"]
},
"data_attachment": {
"file_format": "FILE_FORMAT_CSV",
"widgets": [
{
"page_id": "YOUR_PAGE_ID",
"widget_id": "YOUR_WIDGET_ID"
}
],
"include_applied_filters": true
}
}
}
}
}
]
}Submit the payload using:
curl -X POST \
"$DATABRICKS_HOST/api/2.2/jobs/create" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @job.jsonYou can then verify the saved configuration using:
databricks jobs get <job-id> --output jsonMy Actual test results:
I also tested the Databricks Terraform provider versions v1.109.0 and v1.137.0.
Both terraform validate and terraform plan failed with:
Error: Unsupported block type
Blocks of type "attachment" are not expected here.But, The latest tested provider, v1.140.0 (published October 26, 2026), exposes native page_attachment and data_attachment blocks under dashboard_task.subscription.attachment.
supported Terraform structure:
resource "databricks_job" "dashboard_email" {
name = "dashboard-email-with-attachments"
task {
task_key = "dashboard_snapshot"
dashboard_task {
dashboard_id = var.dashboard_id
warehouse_id = var.warehouse_id
subscription {
paused = true
subscribers {
user_name = var.recipient_email
}
attachment {
page_attachment {
page_selection = "PAGE_SELECTION_SUBSET"
page_ids = ["page_99999"]
}
data_attachment {
file_format = "FILE_FORMAT_CSV"
include_applied_filters = true
widgets {
page_id = "page_99999"
widget_id = "bar_99999"
}
}
}
}
}
}
}Validation: I successfully deployed the dashboard job using Terraform provider v1.140.0 with native PDF/CSV attachment configuration. terraform validate, plan, and apply all passed. The Jobs API confirmed the attachment settings were retained, the dashboard task run completed with SUCCESS and email delivery also confirmed.
Recommendation: For straightforward scheduled dashboard emails, use the Lakeflow Jobs Dashboard task UI, which supports PDF page and widget-data attachments.
For declarative automation, Terraform provider v1.140.0 is a validated option, with successful deployment, execution, and email receipt confirmed.
The Jobs REST API remains an alternative for programmatic configs or older Terraform provider versions that lack native attachment support.
References: