data

Export a panel's query result as CSV or XLSX.

Re-runs the panel's query through the SAME pushdown path as POST /v1/data/query (ADR-0011, parameter-bound per DVT-7 — an export is a re-run, never a privileged side channel), then streams the result rows serialized as CSV or XLSX. Honors the same tenant gate and connection/role RBAC as a normal panel query: a cross-tenant sourceId returns 404, and the query runs under the same warehouse identity (no privilege escalation via export).

Requires the data:export capability (DVT-127) — enforced server-side, not only in the UI. Results are never served from the result cache: an export is a deliberate data-egress event, so it always reflects live rows and is recorded as an audit_logs entry (who/what/when/row-count).

View-state (v1): send the panel's CURRENT params (dashboard filter selections + drill state) so what-you-see-is-what-you-export at the filter level. The exported rows are the FLAT, query-ordered result — client-side table column sort/filter (DVT-135) and grouped/pivot rollups (DVT-113) are not replayed server-side in v1. The result inherits the engine's row cap; X-DVT-Truncated: true marks a cut-off.

XLSX cells are typed (numbers and booleans are native cells, not stringified); the header row uses the resolved column labels.

post/v1/data/export

Request

  • Base URL: http://localhost:8080
  • URL: http://localhost:8080/v1/data/export
  • Auth: one of:
    • API key in cookie dvt_session
    • HTTP bearer

Request body

sourceIdstring required

Connection name or UUID (resolved per connection-as-code.md).

querystring required

SQL to execute against the source via pushdown.

paramsobject

Optional named query parameters — send the panel's current dashboard-filter and drill state here so the export matches what is displayed (DVT-137 v1).

format'csv' | 'xlsx' required

Serialization format for the exported result.

filenamestring

Optional download filename (without extension; the extension is forced to match format). Sanitized server-side. Defaults to "export".

sheetNamestring

Optional XLSX worksheet name (ignored for CSV). Sanitized and truncated to Excel's 31-character sheet-name limit; defaults to "Data" when empty or made entirely of characters Excel forbids in a sheet name.

style'data' | 'formatted'

"formatted" (DVT-4196) BAKES the panel's rendered colors/fonts as static cell styles — never Excel conditional-formatting rules, color-scale rules, or formulas, per the DVT-4195 decision (the workbook is a faithful snapshot of the render, not a live model). "data" (the default) is the flat DVT-4174 workbook: labels, number formats, frozen header, autofilter, widths. Ignored for format: csv. style itself is always validated (400 on any other value), but the formatted-only fields below — conditionalFormat, frozenColumns, tokens, and each column's align/textStyle/conditionalFormat/ colorScale/width/wrap — are only validated for style: formatted, because that is the only style that reads them: a style: data request carrying a saved panel's presentation slices returns the DVT-4174 bytes rather than a 400.

frozenColumnsinteger

Freezes the first N output columns (TableSpec.frozenColumns). Formatted style only; clamped server-side to the output column count.

tokensobject

The client's RESOLVED theme token map ({token.name} → literal), so token refs inside rules/textStyle/palettes resolve to exactly what was on screen. The server has no theme/preset resolver of its own. Formatted style only. At most 1000 entries, keys and values at most 200 characters — a larger map is rejected with 400.

Response

The serialized export file (CSV or XLSX) as an attachment.

Changes

No recorded changes to this operation across all 1 revision of this API.