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

# Export MDX query results to file

> Exports the result of a MDX query in CSV or Arrow format to a file in the server or in the cloud.

Local Server Export:
Files are exported to directories under the system temporary directory:
- Linux/Unix: `/tmp/<directoryName>`
- Windows: `C:\Users\<userName>\AppData\Local\Temp\<directoryName>`

The target directory must already exist before export.
The export will fail if the directory does not exist.

Cloud Export:
Cloud exports are supported for configured cloud storage providers.
For cloud exports, the `directoryName` should specify the cloud path (e.g., S3 bucket path).




## OpenAPI

````yaml post /activeviam/pivot/rest/v9/cube/dataexport/export
openapi: 3.0.0
info:
  title: Atoti REST services
  version: 6.1.18-SNAPSHOT
servers:
  - description: Generated server url
    url: http://localhost:9090
security: []
tags:
  - description: Implementation of the REST API controller for an ActivePivot database.
    name: Database REST API
  - description: >
      XML for Analysis (XMLA) endpoint for executing MDX queries and OLAP
      discovery operations.


      This endpoint implements the XMLA protocol which is used by:

      - Microsoft Excel and other OLAP clients

      - Custom BI tools that support XMLA connectivity


      The endpoint supports both text XML and binary XML formats for improved
      performance.
    name: XMLA API
  - description: Definition of REST API to query data from ActivePivot (V10).
    name: Query REST API (V10)
  - description: Definition of REST API to query data from ActivePivot (V9).
    name: Query REST API (V9)
  - description: Implementation of the REST Bulk API of the content server (version 8).
    name: Bulk REST API
  - description: Implementation of the REST API of the content server.
    name: Content Server REST API
  - description: Implementation of the REST API controller for an ActivePivot database.
    name: Database REST API v9
  - description: ' Definition of the REST service returning the list of services exposed by an application.'
    name: Version REST API
  - description: Rest Service providing the discovery information.
    name: Discovery REST API
  - description: API to access measures information.
    name: Diagnostics API
  - description: JSON Web Token (JWT) endpoint.
    name: JWT API
  - description: >
      Endpoints to retrieve and manage query history.


      **Note:** This API is experimental and may change in future versions
      without notice.
    name: Query History REST API (Experimental)
  - description: Description of REST API to configure an ActivePivot application.
    name: Configuration REST API
  - description: API to export the result of MDX queries
    name: Data Export
  - description: >
      GetAggregatesQuery (GAQ) REST API for executing OLAP queries.


      This API provides a programmatic way to execute GetAggregatesQuery
      operations

      against Atoti cubes. Results and updates are streamed in Apache Arrow
      format for efficient

      data transfer and processing.
    name: Continuous GAQ Query REST API (Experimental)
  - description: Endpoints for AI-based optimization of Atoti cubes
    name: AI Optimizer
  - description: >
      GetAggregatesQuery (GAQ) REST API for executing OLAP queries.


      This API provides a programmatic way to execute GetAggregatesQuery
      operations

      against Atoti cubes. Results are returned in Apache Arrow format for
      efficient

      data transfer and processing.


      **Note:** This API is experimental and may change in future versions
      without notice.
    name: GAQ Query REST API (Experimental)
  - description: Implementation of the REST Bulk API of the content server.
    name: Bulk REST API
paths:
  /activeviam/pivot/rest/v9/cube/dataexport/export:
    post:
      tags:
        - Data Export
      summary: Export MDX query results to file
      description: >
        Exports the result of a MDX query in CSV or Arrow format to a file in
        the server or in the cloud.


        Local Server Export:

        Files are exported to directories under the system temporary directory:

        - Linux/Unix: `/tmp/<directoryName>`

        - Windows: `C:\Users\<userName>\AppData\Local\Temp\<directoryName>`


        The target directory must already exist before export.

        The export will fail if the directory does not exist.


        Cloud Export:

        Cloud exports are supported for configured cloud storage providers.

        For cloud exports, the `directoryName` should specify the cloud path
        (e.g., S3 bucket path).
      operationId: mdxExport
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JsonDataExportOrder'
        description: The MDX query to run and export options
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                description: Empty export success response
                example: {}
                type: string
          description: The export was a success
        '500':
          content:
            application/json:
              schema:
                description: Export error response
                example:
                  error: Export failed
                  message: The cube does not exist
                type: string
          description: The export failed
components:
  schemas:
    JsonDataExportOrder:
      properties:
        jsonMdxQuery:
          $ref: '#/components/schemas/JsonMdxQuery'
        outputConfiguration:
          $ref: '#/components/schemas/IJsonOutputConfiguration'
      type: object
    JsonMdxQuery:
      properties:
        context:
          additionalProperties:
            type: string
          type: object
        mdx:
          type: string
      type: object
    IJsonOutputConfiguration:
      properties:
        columnFormatters:
          items:
            additionalProperties:
              type: string
            type: object
          type: array
        fileConfiguration:
          $ref: '#/components/schemas/JsonFileConfiguration'
        format:
          type: string
      type: object
    JsonFileConfiguration:
      properties:
        directoryName:
          type: string
        fileName:
          type: string
        maxBatchesPerFile:
          format: int32
          type: integer
        maxLinesPerFile:
          format: int32
          type: integer
        useMultipleFiles:
          type: boolean
        useZipFile:
          type: boolean
      type: object

````