Export custom client reports
Export data using custom SQL queries with dynamic parameters. This endpoint allows you to execute pre-configured SQL queries with customizable parameters that replace placeholders in the query.
How Parameters Work
- SQL Query Placeholders: Custom exports contain SQL queries with placeholders like
{limit}
,{offset}
,{customerId}
- Parameter Resolution: Parameters are resolved in this order:
- GET query parameters (highest priority)
- Default values from export configuration
- Required parameters will throw an error if missing
- Security: All parameters are safely bound using prepared statements
Example Custom Export Configuration
{
"label": "Customer Events Report",
"sqlQuery": "SELECT id, type, createdAt FROM event WHERE customerId = {customerId} ORDER BY id DESC LIMIT {limit} OFFSET {offset}",
"parameters": [
{
"key": "customerId",
"label": "Customer ID",
"description": "The customer to export events for",
"defaultValue": null
},
{
"key": "limit",
"label": "Limit",
"description": "Maximum number of records to return",
"defaultValue": "100"
},
{
"key": "offset",
"label": "Offset",
"description": "Number of records to skip",
"defaultValue": "0"
}
]
}
Example Usage
GET /api/mind/export/customData?exportId=0&format=json&customerId=12345&limit=50&offset=0
This would execute:
SELECT id, type, createdAt FROM event WHERE customerId = ? ORDER BY id DESC LIMIT ? OFFSET ?
With parameters: [12345, 50, 0]
Authorizations
Cookie-based authentication
Query Parameters
The format of the export
xlsx
, csv
, json
The ID of the export configuration to use. This corresponds to the index in the
customDataExports
settings array. If null, the default export as configured
in the customDataExportSelected
setting will be used.
Dynamic parameters that replace placeholders in the SQL query.
Any parameter defined in the export configuration can be overridden via GET parameters. Parameter names should match the placeholders in the SQL query (without the curly braces).
Parameter Resolution Logic:
- If provided as GET parameter → use that value
- If not provided but has default value → use default value
- If not provided and no default → throw error (parameter required)
Common Parameter Examples:
limit=100
→ replaces{limit}
placeholderoffset=0
→ replaces{offset}
placeholdercustomerId=12345
→ replaces{customerId}
placeholderstartDate=2024-01-01
→ replaces{startDate}
placeholderendDate=2024-12-31
→ replaces{endDate}
placeholderstatus=active
→ replaces{status}
placeholderdepartmentId=5
→ replaces{departmentId}
placeholder
Response
Successful operation
The response is of type object[]
.