> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enneo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

This endpoint should only be used if standard export endpoints (for tickets, messages, worklog, survey, etc.) do not suffice. It is an adanced feature and every query requires prior approval by your Enneo account manager.

## How Parameters Work

1. **SQL Query Placeholders**: Custom exports contain SQL queries with placeholders like `{limit}`, `{offset}`, `{customerId}`
2. **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
3. **Security**: All parameters are safely bound using prepared statements

## Example Custom Export Configuration
```json
{
  "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:
```sql
SELECT id, type, createdAt FROM event WHERE customerId = ? ORDER BY id DESC LIMIT ? OFFSET ?
```
With parameters: `[12345, 50, 0]`




## OpenAPI

````yaml https://dev.enneo.dev/api/mind/docs/open-api get /export/customData
openapi: 3.0.0
info:
  version: '1'
  title: enneo.MIND API
  description: This describes the API of enneo Mind, the main ticketing backend
  contact:
    name: enneo GmbH
    email: richard@enneo.ai
  license:
    name: Proprietary software
    url: https://enneo.ai
servers:
  - url: https://demo.enneo.ai/api/mind
    description: Production server, demo client
  - url: https://main.enneo.dev/api/mind
    description: Development main branch
  - url: http://localhost:8005/api/mind
    description: Local development server
security:
  - bearerAuth:
      - api
  - cookieAuth:
      - api
paths:
  /export/customData:
    get:
      tags:
        - Export
      summary: Export custom client reports
      description: >
        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.


        This endpoint should only be used if standard export endpoints (for
        tickets, messages, worklog, survey, etc.) do not suffice. It is an
        adanced feature and every query requires prior approval by your Enneo
        account manager.


        ## How Parameters Work


        1. **SQL Query Placeholders**: Custom exports contain SQL queries with
        placeholders like `{limit}`, `{offset}`, `{customerId}`

        2. **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
        3. **Security**: All parameters are safely bound using prepared
        statements


        ## Example Custom Export Configuration

        ```json

        {
          "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:

        ```sql

        SELECT id, type, createdAt FROM event WHERE customerId = ? ORDER BY id
        DESC LIMIT ? OFFSET ?

        ```

        With parameters: `[12345, 50, 0]`
      operationId: exportCustomData
      parameters:
        - name: format
          in: query
          required: false
          description: The format of the export
          schema:
            type: string
            enum:
              - xlsx
              - csv
              - json
            default: As configured in the settings
          example: json
        - name: exportId
          in: query
          required: false
          description: >
            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.
          schema:
            type: integer
            nullable: true
            default: null
          example: 0
        - name: '{parameterName}'
          in: query
          required: false
          description: >
            **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:**

            1. If provided as GET parameter → use that value

            2. If not provided but has default value → use default value  

            3. If not provided and no default → throw error (parameter required)


            **Common Parameter Examples:**

            - `limit=100` → replaces `{limit}` placeholder

            - `offset=0` → replaces `{offset}` placeholder  

            - `customerId=12345` → replaces `{customerId}` placeholder

            - `startDate=2024-01-01` → replaces `{startDate}` placeholder

            - `endDate=2024-12-31` → replaces `{endDate}` placeholder

            - `status=active` → replaces `{status}` placeholder

            - `departmentId=5` → replaces `{departmentId}` placeholder
          schema:
            type: string
          examples:
            limit:
              summary: Limit parameter
              value: '100'
            offset:
              summary: Offset parameter
              value: '0'
            customerId:
              summary: Customer ID parameter
              value: '12345'
            dateRange:
              summary: Date parameter
              value: '2024-01-01'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: >-
                    The structure depends on the SQL query used in the custom
                    export
                example:
                  - id: 1
                    type: login
                    createdAt: '2024-01-15T10:30:00Z'
                    customerId: 12345
                  - id: 2
                    type: purchase
                    createdAt: '2024-01-14T15:45:00Z'
                    customerId: 12345
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
                description: Excel file containing the export data
            text/csv:
              schema:
                type: string
                format: binary
                description: CSV file containing the export data
        '400':
          description: >-
            Bad request - required parameter missing or invalid export
            configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
              examples:
                missingParameter:
                  summary: Missing required parameter
                  value:
                    error: Parameter 'customerId' is required
                invalidExport:
                  summary: Invalid export ID
                  value:
                    error: Export 5 not found
        '403':
          description: Unauthorized
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT-based authentication
      x-scopes:
        api: Full access to the API
    cookieAuth:
      type: apiKey
      in: cookie
      name: connect.sid
      description: Cookie-based authentication
      x-scopes:
        api: Full access to the API

````