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

# Get export log history

> Retrieve the history of export operations for the authenticated user's organization. This endpoint returns a paginated list of all export activities including tasks, data sources, vehicles, drivers, and other exportable entities.

**Key Features:**
- Returns exports from the last 30 days only (older exports are automatically purged)
- Filters by user email by default (shows only current user's exports)
- Supports filtering by export status, data type, and data name
- Powered by ElasticSearch for fast querying

**Export Status Values:**
- `Processing`: Export is being generated in the background
- `Done`: Export completed successfully, file is ready for download
- `Failed`: Export failed due to an error

**Data Types:**
- `task`: Task exports
- `data`: Data source exports
- `vehicle`: Vehicle exports
- `driver`: Driver exports
- `route`: Route exports

**Important Notes:**
- Export files are stored for 30 days, after which they are automatically deleted
- Download links are S3 presigned URLs with expiration time
- Use this endpoint to monitor background exports initiated via `background=true` parameter



## OpenAPI

````yaml /openapi/public/openapi-importexport.json get /tasks/export-log
openapi: 3.0.0
info:
  title: MileApp API - ImportExport
  version: 3.0.0
  description: MileApp API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Data Import
    description: >-
      The Data Import module allows users to upload and import data source
      records from Excel or CSV files. Import operations are processed in the
      background via queue system for scalability and can handle large datasets.
      The import process validates data against data type schemas, tracks
      processing status in real-time, and generates detailed reports including
      failed records for review. All import activities can be monitored through
      import-monitoring endpoints with 30-day data retention.
  - name: Export Task
    description: >-
      The Export Task module provides functionality to export task data and data
      source records to various formats (XLSX, JSON). It supports both direct
      export for small datasets and background processing for large exports.
      Users can customize exports using export configurations, filter data by
      multiple criteria, and monitor export operations through export logs.
      Export files are stored securely with 30-day retention period.
  - name: Export Config
    description: >-
      The Export Config module is used to save and manage the specific fields
      that a user wants included in export results. This allows users to
      customize their exported data by selecting only the necessary fields for
      each export, ensuring that the output contains exactly the information
      they need.


      **To see the details of export config object, please follow [this
      link](#tag/export_config_model)**
  - name: Import Config
    description: >-
      The Import Config module saves and manages column mapping presets for bulk
      import features across MileApp. Users can store field-to-Excel-column
      mappings so they can be reused across multiple imports. Each config is
      linked to a specific resource and contains the mapping between its fields
      and Excel header columns.
paths:
  /tasks/export-log:
    get:
      tags:
        - Export Task
      summary: Get export log history
      description: >-
        Retrieve the history of export operations for the authenticated user's
        organization. This endpoint returns a paginated list of all export
        activities including tasks, data sources, vehicles, drivers, and other
        exportable entities.


        **Key Features:**

        - Returns exports from the last 30 days only (older exports are
        automatically purged)

        - Filters by user email by default (shows only current user's exports)

        - Supports filtering by export status, data type, and data name

        - Powered by ElasticSearch for fast querying


        **Export Status Values:**

        - `Processing`: Export is being generated in the background

        - `Done`: Export completed successfully, file is ready for download

        - `Failed`: Export failed due to an error


        **Data Types:**

        - `task`: Task exports

        - `data`: Data source exports

        - `vehicle`: Vehicle exports

        - `driver`: Driver exports

        - `route`: Route exports


        **Important Notes:**

        - Export files are stored for 30 days, after which they are
        automatically deleted

        - Download links are S3 presigned URLs with expiration time

        - Use this endpoint to monitor background exports initiated via
        `background=true` parameter
      operationId: GetExportLog
      parameters:
        - name: sortBy
          in: query
          required: false
          description: >-
            Field name to sort the results by. Sorts the export log entries
            based on the specified field.

            **Example:** `requestAt`, `status`, `dataType`, `dataName`

            **Default:** `requestAt`
          schema:
            type: string
        - name: sortOrder
          in: query
          required: false
          description: >-
            Sort order for the results. Use `asc` for ascending or `desc` for
            descending order.

            **Example:** `desc`

            **Default:** `desc`
          schema:
            type: string
            enum:
              - asc
              - desc
        - name: limit
          in: query
          required: false
          description: >-
            Maximum number of export log entries to return per page. Controls
            pagination size.

            **Example:** `20`

            **Default:** `10`

            **Min:** `1`, **Max:** `100`
          schema:
            type: integer
            minimum: 1
            maximum: 100
        - name: page
          in: query
          required: false
          description: >-
            Page number for pagination. Use in combination with `limit` to
            navigate through results.

            **Example:** `1`

            **Default:** `1`

            **Min:** `1`
          schema:
            type: integer
            minimum: 1
        - name: dataName
          in: query
          required: false
          description: >-
            Filter export logs by the name of the exported data. Useful for
            finding exports of specific entities.

            **Example:** `Task Export - January 2024`, `Driver List`
          schema:
            type: string
        - name: dataType
          in: query
          required: false
          description: >-
            Filter export logs by type of data that was exported. Helps narrow
            down results to specific export categories.

            **Example:** `task`, `data`, `vehicle`
          schema:
            type: string
            enum:
              - task
              - data
              - vehicle
              - driver
              - route
        - name: status
          in: query
          required: false
          description: >-
            Filter export logs by processing status. Use to find exports that
            are still processing, completed, or failed.

            **Example:** `Done`, `Processing`, `Failed`
          schema:
            type: string
            enum:
              - Processing
              - Done
              - Failed
        - name: email
          in: query
          required: false
          description: >-
            Filter export logs by user email who initiated the export. If not
            provided, defaults to the authenticated user's email.

            **Example:** `john.doe@mile.app`

            **Default:** Current user's email
          schema:
            type: string
      responses:
        '200':
          description: Success - Export log retrieved
          content:
            application/json:
              schema:
                type: object
                title: ExportLogResponse
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  total:
                    description: >-
                      Total number of export log entries matching the filters
                      (across all pages).
                    type: integer
                  data:
                    description: Array of export log entries from ElasticSearch.
                    type: array
                    items:
                      type: object
                      properties:
                        _index:
                          description: ElasticSearch index name
                          type: string
                        _type:
                          description: ElasticSearch document type
                          type: string
                        _id:
                          description: Unique identifier for the export log entry
                          type: string
                        _score:
                          description: ElasticSearch relevance score
                          type: number
                        _source:
                          description: Actual export log data
                          type: object
                          properties:
                            organizationId:
                              description: Organization ID that owns this export
                              type: string
                            dataType:
                              description: >-
                                Type of data that was exported (task, data,
                                vehicle, etc.)
                              type: string
                            dataName:
                              description: Name or description of the export
                              type: string
                            status:
                              description: >-
                                Current status of the export (Processing, Done,
                                Failed)
                              type: string
                            requestAt:
                              description: >-
                                Timestamp when export was requested (ISO 8601
                                format)
                              type: string
                            completedAt:
                              description: >-
                                Timestamp when export was completed (ISO 8601
                                format, null if still processing)
                              type: string
                            email:
                              description: Email of user who initiated the export
                              type: string
                            fileUrl:
                              description: >-
                                S3 download URL for the exported file (presigned
                                URL with expiration)
                              type: string
                            fileType:
                              description: Format of the exported file (xlsx, json, zip)
                              type: string
                            totalRecords:
                              description: Total number of records exported
                              type: integer
                            errorMessage:
                              description: >-
                                Error message if export failed (null if
                                successful)
                              type: string
                  params:
                    description: >-
                      ElasticSearch query parameters used for this request (for
                      debugging purposes).
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  total: 25
                  data:
                    - _index: export
                      _type: _doc
                      _id: exp_61e5477611c1b26cef05d37c
                      _score: 1
                      _source:
                        organizationId: 61c2fbaaf27b374e8913fe72
                        dataType: task
                        dataName: Task Export - January 2024
                        status: Done
                        requestAt: '2024-01-15T10:30:00+00:00'
                        completedAt: '2024-01-15T10:32:15+00:00'
                        email: john.doe@mile.app
                        fileUrl: >-
                          https://staticdev.mile.app/production-mile/20240115/task_61c2fbaaf27b374e8913fe72_1705315800.xlsx
                        fileType: xlsx
                        totalRecords: 1247
                        errorMessage: null
                    - _index: export
                      _type: _doc
                      _id: exp_61e5477611c1b26cef05d38d
                      _score: 1
                      _source:
                        organizationId: 61c2fbaaf27b374e8913fe72
                        dataType: data
                        dataName: Customer Data Export
                        status: Processing
                        requestAt: '2024-01-15T11:00:00+00:00'
                        completedAt: null
                        email: john.doe@mile.app
                        fileUrl: null
                        fileType: xlsx
                        totalRecords: 0
                        errorMessage: null
                    - _index: export
                      _type: _doc
                      _id: exp_61e5477611c1b26cef05d39e
                      _score: 1
                      _source:
                        organizationId: 61c2fbaaf27b374e8913fe72
                        dataType: vehicle
                        dataName: Fleet Report - December 2023
                        status: Failed
                        requestAt: '2024-01-14T09:00:00+00:00'
                        completedAt: '2024-01-14T09:05:30+00:00'
                        email: john.doe@mile.app
                        fileUrl: null
                        fileType: xlsx
                        totalRecords: 0
                        errorMessage: 'Query timeout: Dataset too large'
                  params:
                    from: 0
                    size: 10
                    query:
                      bool:
                        must:
                          - term:
                              organizationId.keyword: 61c2fbaaf27b374e8913fe72
                          - range:
                              requestAt:
                                lte: '2024-01-15T12:00:00+00:00'
                                gte: '2023-12-16T12:00:00+00:00'
                    sort:
                      - requestAt:
                          order: desc
        '400':
          description: Bad Request - Invalid query parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Invalid limit parameter. Must be between 1 and 100.
                  data:
                    type: array
                    example: []
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Unauthorized
        '403':
          description: Forbidden - User lacks permission to view export logs
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: You do not have permission to view export logs
        '500':
          description: Server Error - ElasticSearch or internal error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: ElasticSearch connection failed
                  data:
                    type: array
                    example: []
                    items:
                      type: object
                      additionalProperties: true
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                      file:
                        type: string
                      line_of_code:
                        type: integer
                      code:
                        type: integer
      deprecated: false
      security:
        - bearerAuth: []
      x-code-samples:
        - lang: cURL
          source: >-
            curl -X GET
            "https://apiweb.mile.app/api/v3/tasks/export-log?page=1&limit=10&sortBy=requestAt&sortOrder=desc"
            \
              -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
        - lang: cURL - Filter by Status
          source: >-
            curl -X GET
            "https://apiweb.mile.app/api/v3/tasks/export-log?status=Done&dataType=task&limit=20"
            \
              -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
        - lang: JavaScript - Axios
          source: |-
            const axios = require('axios');

            const getExportLog = async () => {
              try {
                const response = await axios.get(
                  'https://apiweb.mile.app/api/v3/tasks/export-log',
                  {
                    params: {
                      page: 1,
                      limit: 10,
                      sortBy: 'requestAt',
                      sortOrder: 'desc',
                      status: 'Done',
                      dataType: 'task'
                    },
                    headers: {
                      'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
                    }
                  }
                );
                
                console.log('Total exports:', response.data.total);
                response.data.data.forEach(log => {
                  const source = log._source;
                  console.log(`Export: ${source.dataName}`);
                  console.log(`Status: ${source.status}`);
                  console.log(`Download: ${source.fileUrl}`);
                  console.log('---');
                });
              } catch (error) {
                console.error('Failed to fetch export log:', error.response?.data || error.message);
              }
            };

            getExportLog();
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````