# POST /api/v1/dashboards/{dashboard_id}/export

> Export a dashboard to CSV or PDF

- **Tag:** dashboards
- **Operation ID:** `export_dashboard_api_v1_dashboards__dashboard_id__export_post`

## Description

Queue an asynchronous export of this dashboard and return a task id. Poll the standard report task-status endpoint (`GET /api/v1/task/{task_id}`) for progress and the download link — this reuses the report pipeline rather than adding a second one.

Exports read **stored snapshots only** and never re-execute widget sources, so an export is exactly as fresh as the dashboard and costs no analytical queries. Charts are flattened to their underlying tabular data: CSV emits one section per widget, PDF renders those same tables. No chart images are rendered server-side.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `dashboard_id` (path, string, required)

## Request body

Schema: `ExportDashboardRequest`

- `output_format` (string) (one of: csv, pdf)
- `widget_ids` (array · string)
- `include_empty` (boolean) — Include widgets that have no snapshot data.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_DashboardExportResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (DashboardExportResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/dashboards/{dashboard_id}/export' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "output_format": "csv",
  "widget_ids": [],
  "include_empty": false
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/dashboards/{dashboard_id}/export', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "output_format": "csv",
  "widget_ids": [],
  "include_empty": false
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "output_format": "csv",
  "widget_ids": [],
  "include_empty": false
}

response = httpx.post("https://api.ondayzero.com/api/v1/dashboards/{dashboard_id}/export", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/dashboards/export-dashboard
- OpenAPI slice: https://www.ondayzero.com/docs/reference/dashboards/export-dashboard/openapi.json
- Other endpoints in **dashboards**: https://www.ondayzero.com/docs/reference/dashboards
