# Export Templates

Reusable export configurations that combine a column layout, filters, sort order, and output format into a named template. Run a template to get XLSX or CSV data; preview returns the first 10 rows. Named views let each user persist their own filter/sort variant on a shared template. Scopes: exports:read, exports:write, exports:delete.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### GET /exports/field-catalog

Discover which fields are available as columns and filters for a given root entity. Returns filter_fields (with allowed operator sets per field type) and column_fields (source + relation options). Call this before building a create_export_template payload so column IDs and filter ops are correct.

**Scopes:** `exports:read` — [full detail](./export-templates/get-exports-field-catalog.md)

### GET /exports/templates

List all export templates for this workspace.

**Scopes:** `exports:read` — [full detail](./export-templates/get-exports-templates.md)

### GET /exports/templates/:id

Get a single export template with full column, filter, and output config.

**Scopes:** `exports:read` — [full detail](./export-templates/get-exports-templates-id.md)

### POST /exports/templates

Create an export template. Define columns (root fields or relation fields), filters, optional sort, and output format.

**Scopes:** `exports:write` — [full detail](./export-templates/post-exports-templates.md)

### PATCH /exports/templates/:id

Update an export template. All body fields are optional; send only the fields you want to change.

**Scopes:** `exports:write` — [full detail](./export-templates/patch-exports-templates-id.md)

### DELETE /exports/templates/:id

Delete an export template and all its saved views.

**Scopes:** `exports:delete` — [full detail](./export-templates/delete-exports-templates-id.md)

### POST /exports/templates/:id/preview

Preview the first 10 rows of an export template (or a saved view). Returns JSON with headers and rows -- useful for verifying filter logic before running a full export. Filters, sort, and column layout from the template (or overrides in the request body) are applied. All filter operators are supported: tags use in (OR/"has any of") / not_in (NOR/"has none of"). Legacy not_contains is a back-compat alias for not_in.

**Scopes:** `exports:read` — [full detail](./export-templates/post-exports-templates-id-preview.md)

### POST /exports/templates/:id/run

Run an export template and download the resulting XLSX or CSV file. Up to 250,000 rows are exported (X-Truncated: 1 header if the cap is hit). Optionally apply a saved view's filter/sort overrides. Supports all filter operators: tags use in (OR/"has any of") / not_in (NOR/"has none of"); not_contains is a back-compat alias for not_in.

**Scopes:** `exports:read` — [full detail](./export-templates/post-exports-templates-id-run.md)

### GET /exports/templates/:id/views

List all saved views for an export template.

**Scopes:** `exports:read` — [full detail](./export-templates/get-exports-templates-id-views.md)

### POST /exports/templates/:id/views

Create a saved view on an export template. A view stores a per-user filter/sort overlay without modifying the base template.

**Scopes:** `exports:write` — [full detail](./export-templates/post-exports-templates-id-views.md)

### PATCH /exports/templates/:template_id/views/:id

Update a saved view name, filters, or sort.

**Scopes:** `exports:write` — [full detail](./export-templates/patch-exports-templates-template-id-views-id.md)

### DELETE /exports/templates/:template_id/views/:id

Delete a saved view.

**Scopes:** `exports:delete` — [full detail](./export-templates/delete-exports-templates-template-id-views-id.md)
