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

# Create Orders Export

> Creates a downloadable CSV file containing a list of orders.

The parameters listed in the payload resembles headers in the CSV file. To include a parameter to the file, add it to the `parameters.fields` object in the request body.

The available filters are all [order object](/api-reference/orders/order-calculated-object) attributes. Additionally, any metadata defined in the metadata schema can be exported.

Passing an empty JSON will generate a file containing three default fields: `id`, `source_id`, and `status`.

The fields array is an array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields:

| **Field** | **Definition** | **Example Export** |
|:---|:---|:---|
| `id` | Unique order ID. | ord_A69RIxEdRsPuC6i8gFGVHUft |
| `source_id` | Unique order source ID. | 8638 |
| `created_at` | Timestamp in ISO 8601 format representing the date and time when the order was created. | 2022-03-09T09:16:32.521Z |
| `updated_at` | Timestamp in ISO 8601 format representing the date and time when the order was last updated. | 2022-03-09T09:16:33.331Z |
| `status` | Order status. | `PAID`, `CREATED`, `FULFILLED`, `CANCELED` |
| `amount` | Total amount of order items. | 7700 |
| `discount_amount` | Represents total amount of the discount applied to whole cart. | 500 |
| `items_discount_amount` | Represents total amount of the discount applied to order line items. | 100 |
| `total_discount_amount` | All discounts applied to the order including discounts applied to particular order line items and discounts applied to the whole cart. | 600 |
| `total_amount` | Total order amount after applying all discounts. | 7100 |
| `customer_id` | Customer unique ID. | cust_2G4fUQdCXUqp35nXNleav7bO |
| `referrer_id` | Referrer unique ID. | cust_IkrTR674vvQvr9a4rDMiqglY |
| `metadata` | Returns all order metadata. | Response will include all order metadata. |
| `metadata.X` | Where X is the name of a particular order metadata property. | The returned value will depend on the type of data defined in the Dashboard > Project Settings > Metdata Schemas > Order. |



## OpenAPI

````yaml /openapi/orders.json post /v1/orders/export
openapi: 3.0.1
info:
  title: Voucherify API - Orders
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /v1/orders/export:
    post:
      tags:
        - Orders
      summary: Create Orders Export
      description: >-
        Creates a downloadable CSV file containing a list of orders.


        The parameters listed in the payload resembles headers in the CSV file.
        To include a parameter to the file, add it to the `parameters.fields`
        object in the request body.


        The available filters are all [order
        object](/api-reference/orders/order-calculated-object) attributes.
        Additionally, any metadata defined in the metadata schema can be
        exported.


        Passing an empty JSON will generate a file containing three default
        fields: `id`, `source_id`, and `status`.


        The fields array is an array of strings containing the data in the
        export. These fields define the headers in the CSV file. The array can
        be a combination of any of the following available fields:


        | **Field** | **Definition** | **Example Export** |

        |:---|:---|:---|

        | `id` | Unique order ID. | ord_A69RIxEdRsPuC6i8gFGVHUft |

        | `source_id` | Unique order source ID. | 8638 |

        | `created_at` | Timestamp in ISO 8601 format representing the date and
        time when the order was created. | 2022-03-09T09:16:32.521Z |

        | `updated_at` | Timestamp in ISO 8601 format representing the date and
        time when the order was last updated. | 2022-03-09T09:16:33.331Z |

        | `status` | Order status. | `PAID`, `CREATED`, `FULFILLED`, `CANCELED`
        |

        | `amount` | Total amount of order items. | 7700 |

        | `discount_amount` | Represents total amount of the discount applied to
        whole cart. | 500 |

        | `items_discount_amount` | Represents total amount of the discount
        applied to order line items. | 100 |

        | `total_discount_amount` | All discounts applied to the order including
        discounts applied to particular order line items and discounts applied
        to the whole cart. | 600 |

        | `total_amount` | Total order amount after applying all discounts. |
        7100 |

        | `customer_id` | Customer unique ID. | cust_2G4fUQdCXUqp35nXNleav7bO |

        | `referrer_id` | Referrer unique ID. | cust_IkrTR674vvQvr9a4rDMiqglY |

        | `metadata` | Returns all order metadata. | Response will include all
        order metadata. |

        | `metadata.X` | Where X is the name of a particular order metadata
        property. | The returned value will depend on the type of data defined
        in the Dashboard > Project Settings > Metdata Schemas > Order. |
      operationId: create-order-export
      parameters: []
      requestBody:
        description: Specify which order parameters you would like to export.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrdersExportCreateRequestBody'
            examples:
              Using fields:
                value:
                  parameters:
                    fields:
                      - id
                      - source_id
                      - status
                      - created_at
                      - updated_at
                      - amount
                      - discount_amount
                      - items_discount_amount
                      - total_discount_amount
                      - total_amount
                      - customer_id
                      - referrer_id
                      - metadata.payment_mean
              Using fields and filters:
                value:
                  parameters:
                    fields:
                      - id
                      - source_id
                      - status
                      - created_at
                      - updated_at
                      - amount
                      - discount_amount
                      - items_discount_amount
                      - total_discount_amount
                      - total_amount
                      - customer_id
                      - referrer_id
                      - metadata.payment_mean
                    order: '-updated_at'
                    filters:
                      discount_amount:
                        conditions:
                          $more_than: 100000
        required: true
      responses:
        '200':
          description: >-
            Returns the `id` of the export object and `status` of the file
            generation process. The `id` is used in the [Get
            Export](/api-reference/exports/get-export) method to generate the
            url for the downloadable CSV file or in the [Download
            Export](/api-reference/exports/download-export) method to return the
            contents of the CSV file. The status indicates whether the file has
            been scheduled for creation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrdersExportCreateResponseBody'
              examples:
                Example:
                  value:
                    id: exp_pT2Y1mgYsAgRAqsWTGf7PQX7
                    object: export
                    created_at: '2022-09-09T10:45:52.362Z'
                    status: SCHEDULED
                    channel: API
                    exported_object: order
                    parameters:
                      fields:
                        - id
                        - source_id
                        - status
                        - created_at
                        - updated_at
                        - amount
                        - discount_amount
                        - items_discount_amount
                        - total_discount_amount
                        - total_amount
                        - customer_id
                        - referrer_id
                        - metadata.payment_mean
                    result: null
                    user_id: null
        '400':
          description: Returns an error if the request payload is specified incorrectly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Invalid payload:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: >-
                      Property .parameters.filters should match either
                      `filters[${field}][conditions][${condition}][${index}]` or
                      `filters[${field}][conditions][${condition}]` format and
                      condition must be one of: $in, $not_in, $in_location,
                      $not_in_location, $is, $is_days_ago, $is_days_in_future,
                      $is_not, $has_value, $is_unknown, $contains, $not_contain,
                      $starts_with, $ends_with, $more_than, $less_than,
                      $more_than_ago, $less_than_ago, $more_than_future,
                      $less_than_future, $more_than_equal, $less_than_equal,
                      $after, $before, $count, $count_less, $count_more, $today,
                      $tomorrow, $yesterday, $this_week, $last_week, $next_week,
                      $this_month, $last_month, $next_month, $this_year,
                      $next_year, $last_year, $is_day_of_month, $is_day,
                      $is_month, $is_year, $today_md, $tomorrow_md,
                      $yesterday_md, $this_week_md, $last_week_md,
                      $next_week_md, $this_month_md, $last_month_md,
                      $next_month_md, $is_days_ago_md, $is_more_days_ago_md,
                      $is_less_days_ago_md, $is_days_in_future_md,
                      $is_more_days_in_future_md, $is_less_days_in_future_md,
                      $is_years_ago, $active, $failed, $in_progress, $expired,
                      $before_start, $enabled, $disabled, $redeemed, $redeemable
                    request_id: v-0c52e783650ae585b2
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - orders
components:
  schemas:
    OrdersExportCreateRequestBody:
      title: Orders Export Create Request Body
      description: Request body schema for **POST** `v1/orders/export`.
      type: object
      properties:
        parameters:
          type: object
          properties:
            order:
              description: >-
                How the export is filtered, where the dash - preceding a sorting
                option means sorting in a descending order.
              allOf:
                - $ref: '#/components/schemas/ExportOrderOrder'
            fields:
              type: array
              description: >-
                Array of strings containing the data in the export. These fields
                define the headers in the CSV file.
              items:
                $ref: '#/components/schemas/ExportOrderFields'
            filters:
              description: Filter conditions.
              allOf:
                - $ref: '#/components/schemas/ExportOrderFilters'
          description: >-
            List of available fields and filters that can be exported with an
            order along with the sorting order of the returned data.
    OrdersExportCreateResponseBody:
      title: Orders Export Create Response Body
      description: Response body schema for **POST** `v1/orders/export`.
      allOf:
        - $ref: '#/components/schemas/ExportScheduledBase'
        - $ref: '#/components/schemas/ExportOrderBase'
    Error:
      title: Error Object
      type: object
      description: Error details
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a885062c80375740f
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
        resource_id:
          type: string
          description: >-
            Unique resource ID that can be used in another endpoint to get more
            details.
          example: rf_0c5d710a87c8a31f86
        resource_type:
          type: string
          description: The resource type.
          example: voucher
        error:
          type: object
          description: Includes additional information about the error.
          properties:
            message:
              type: string
              description: The message configured by the user in a validation rule.
      required:
        - code
        - message
    ExportOrderOrder:
      title: Export Order Order
      type: string
      enum:
        - '-created_at'
        - created_at
        - '-updated_at'
        - updated_at
        - '-status'
        - status
    ExportOrderFields:
      title: Export Order Fields
      type: string
      enum:
        - id
        - source_id
        - created_at
        - updated_at
        - status
        - amount
        - discount_amount
        - items_discount_amount
        - total_discount_amount
        - total_amount
        - customer_id
        - referrer_id
        - metadata
    ExportOrderFilters:
      title: Export Order Filters
      description: Allowed additional properties must start with "metadata."
      type: object
      properties:
        junction:
          $ref: '#/components/schemas/Junction'
        created_at:
          type: object
          properties:
            conditions:
              title: Filters Condition
              type: object
              properties:
                $after:
                  $ref: '#/components/schemas/Any'
                $before:
                  $ref: '#/components/schemas/Any'
        updated_at:
          type: object
          properties:
            conditions:
              title: Filters Condition
              type: object
              properties:
                $after:
                  $ref: '#/components/schemas/Any'
                $before:
                  $ref: '#/components/schemas/Any'
        status:
          $ref: '#/components/schemas/FieldConditions'
        source_id:
          $ref: '#/components/schemas/FieldConditions'
        amount:
          $ref: '#/components/schemas/FieldConditions'
        total_amount:
          $ref: '#/components/schemas/FieldConditions'
        discount_amount:
          $ref: '#/components/schemas/FieldConditions'
        total_discount_amount:
          $ref: '#/components/schemas/FieldConditions'
        items_discount_amount:
          $ref: '#/components/schemas/FieldConditions'
      additionalProperties:
        $ref: '#/components/schemas/FieldConditions'
    ExportScheduledBase:
      title: Export Scheduled Base
      type: object
      properties:
        id:
          type: string
          description: Unique export ID.
        object:
          type: string
          default: export
          enum:
            - export
          description: >-
            The type of object being represented. This object stores information
            about the export.
        created_at:
          type: string
          format: date-time
          description: >-
            Timestamp representing the date and time when the export was
            scheduled in ISO 8601 format.
        status:
          type: string
          description: >-
            Status of the export. Informs you whether the export has already
            been completed, i.e. indicates whether the file containing the
            exported data has been generated.
          default: SCHEDULED
          enum:
            - SCHEDULED
        channel:
          type: string
          description: The channel through which the export was triggered.
        result:
          type: object
          nullable: true
          default: null
          description: Contains the URL of the CSV file.
        user_id:
          type: string
          description: >-
            Identifies the specific user who initiated the export through the
            Voucherify Dashboard; returned when the channel value is WEBSITE.
      required:
        - id
        - object
        - created_at
        - status
        - result
        - user_id
    ExportOrderBase:
      title: Export Orders
      type: object
      properties:
        exported_object:
          type: string
          default: order
          enum:
            - order
          description: The type of object to be exported.
        parameters:
          type: object
          properties:
            order:
              description: >-
                How the export is filtered, where the dash - preceding a sorting
                option means sorting in a descending order.
              allOf:
                - $ref: '#/components/schemas/ExportOrderOrder'
            fields:
              type: array
              description: >-
                Array of strings containing the data in the export. These fields
                define the headers in the CSV file.
              items:
                $ref: '#/components/schemas/ExportOrderFields'
            filters:
              description: Filter conditions.
              allOf:
                - $ref: '#/components/schemas/ExportOrderFilters'
          description: >-
            List of available fields and filters that can be exported with an
            order along with the sorting order of the returned data.
      required:
        - exported_object
    Junction:
      title: Junction
      description: >-
        Logical Operator Between Filters. Filter by conditions set on the
        `junction` parameter indicating how the `conditions` should be accounted
        for in the query. An `AND` is an all-inclusive logical operator, meaning
        the `AND` operator displays a record if **ALL** the conditions separated
        by AND are TRUE, while  an `OR` operator displays a record if **ANY** of
        the conditions separated by OR is TRUE.
      enum:
        - and
        - or
      type: string
    Any:
      title: Any
      type: array
      items:
        oneOf:
          - title: string
            type: string
          - title: string - date
            type: string
            format: date
          - title: string - date-time
            type: string
            format: date-time
          - title: number
            type: number
          - title: object
            type: object
    FieldConditions:
      title: Field Conditions
      type: object
      properties:
        conditions:
          description: >-
            Data filters used to narrow down the data records to be returned in
            the result.
          allOf:
            - $ref: '#/components/schemas/FiltersCondition'
    FiltersCondition:
      title: Filters Condition
      type: object
      properties:
        $in:
          $ref: '#/components/schemas/Any'
        $not_in:
          $ref: '#/components/schemas/Any'
        $is:
          $ref: '#/components/schemas/Any'
        $is_days_ago:
          $ref: '#/components/schemas/Any'
        $is_days_in_future:
          $ref: '#/components/schemas/Any'
        $is_not:
          $ref: '#/components/schemas/Any'
        $has_value:
          $ref: '#/components/schemas/Any'
        $is_unknown:
          $ref: '#/components/schemas/Any'
        $contains:
          $ref: '#/components/schemas/Any'
        $not_contain:
          $ref: '#/components/schemas/Any'
        $starts_with:
          $ref: '#/components/schemas/Any'
        $ends_with:
          $ref: '#/components/schemas/Any'
        $more_than:
          $ref: '#/components/schemas/Any'
        $less_than:
          $ref: '#/components/schemas/Any'
        $more_than_ago:
          $ref: '#/components/schemas/Any'
        $less_than_ago:
          $ref: '#/components/schemas/Any'
        $more_than_future:
          $ref: '#/components/schemas/Any'
        $less_than_future:
          $ref: '#/components/schemas/Any'
        $more_than_equal:
          $ref: '#/components/schemas/Any'
        $less_than_equal:
          $ref: '#/components/schemas/Any'
        $after:
          $ref: '#/components/schemas/Any'
        $before:
          $ref: '#/components/schemas/Any'
        $count:
          $ref: '#/components/schemas/Any'
        $count_less:
          $ref: '#/components/schemas/Any'
        $count_more:
          $ref: '#/components/schemas/Any'
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    X-Voucherify-OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://api.voucherify.io/v1/oauth/token
          scopes:
            api: Gives access to whole server-side API.
            vouchers: >-
              Gives access to all endpoints and methods starting with
              `v1/vouchers`.
            client_api: Gives access to whole client-side API.
            client_vouchers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/vouchers`.
            promotions: >-
              Gives access to all endpoints and methods starting with
              `/v1/promotions`.
            client_promotions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/promotions`
            campaigns: >-
              Gives access to all endpoints and methods starting with
              `v1/campaigns`.
            client_publish: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/publish`.
            exports: >-
              Gives access to all endpoints and methods starting with
              `/v1/exports`.
            publications: >-
              Gives access to all endpoints and methods starting with
              `/v1/publications`.
            client_validate: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validate`.
            validations: >-
              Gives access to all endpoints and methods starting with
              `/v1/validations`.
            client_validations: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validations`.
            qualifications: >-
              Gives access to all endpoints and methods starting with
              `/v1/qualifications`.
            client_qualifications: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/qualifications`.
            client_redeem: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redeem
            redemptions: >-
              Gives access to all endpoints and methods starting with
              `/v1/redemptions`.
            client_redemptions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redemptions`
            customers: >-
              Gives access to all endpoints and methods starting with
              `/v1/customers`.
            client_customers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/customers`.
            orders: >-
              Gives access to all endpoints and methods starting with
              `/v1/orders`.
            products: >-
              Gives access to all endpoints and methods starting with
              `/v1/products`.
            skus: >-
              Gives access to all endpoints and methods starting with
              `/v1/SKUs`.
            validation-rules: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules`.
            validation-rules-assignments: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules-assignments
            segments: >-
              Gives access to all endpoints and methods starting with
              `/v1/segments`.
            events: >-
              Gives access to all endpoints and methods starting with
              `/v1/events`.
            client_events: >-
              Gives access to all endpoints and methods starting with
              `client/v1/events`.
            rewards: >-
              Gives access to all endpoints and methods starting with
              `/v1/rewards`.
            assets: >-
              Gives access to all endpoints and methods starting with
              `/v1/assets`.
            task-results: >-
              Gives access to all endpoints and methods starting with
              `/v1/task-results`.
            loyalties: >-
              Gives access to all endpoints and methods starting with
              `/v1/loyalties`.
            client_consents: >-
              Gives access to all endpoints and methods starting with
              `client/v1/consents`.
            consents: >-
              Gives access to all endpoints and methods starting with
              `/v1/consents`.
            async-actions: >-
              Gives access to all endpoints and methods starting with
              `/v1/async-actions`.
            product-collections: >-
              Gives access to all endpoints and methods starting with
              `/v1/product-collections`.
            categories: >-
              Gives access to all endpoints and methods starting with
              `/v1/categories`.
            metadata-schemas: >-
              Gives access to all endpoints and methods starting with
              `/v1/metadata-schemas`.
            locations: >-
              Gives access to all endpoints and methods starting with
              `/v1/locations`.
            referrals: >-
              Gives access to all endpoints and methods starting with
              `/v1/referrals`.
            trash-bin: >-
              Gives access to all endpoints and methods starting with
              `/v1/trash-bin`.
            templates: >-
              Gives access to all endpoints and methods starting with
              `/v1/templates`.

````