The Export object

/exports endpoint allows you to retrieve Voucherify objects such as vouchers, redemptions, publications, customers, and points expirations as a CSV file. This functionality works asynchronously and comes down to 3 steps:

  • create an export object and return its id so you can track its status
  • trigger a CSV file generation, change the status to SCHEDULED
  • when the generation is over, store the file in S3 and change the status to DONE (now you can get it)

With parameters you can select which fields will be exported and filter out the relevant data

  {
    "fields": [
      "code",
      "voucher_type"
    ],
    "filters": {
      "categories": {
        "conditions": {
          "$in": [
            "postman"
          ]
        }
      }
    }
  }

Fields values

Here is a list of the fields you can export for particular objects.

ObjectFields
voucher"code"
"voucher_type"
"value"
"discount_type"
"campaign"
"category"
"start_date"
"expiration_date"
"gift_balance"
"loyalty_balance"
"redemption_quantity"
"redemption_count"
"active"
"qr_code"
"bar_code"
"metadata"
"metadata.X" where X is a single metadata property
"id"
"is_referral_code"
"created_at"
"updated_at"
"validity_timeframe_interval"
"validity_timeframe_duration"
"validity_day_of_week"
"discount_amount_limit"
"campaign_id"
"additional_info"
"customer_id"
"discount_unit_type"
"discount_unit_effect"
"customer_source_id"
redemption"object"
"date"
"voucher_code"
"campaign"
"promotion_tier_id"
"customer_id"
"tracking_id"
"order_amount"
"gift_amount"
"loyalty_points"
"result"
"failure_code"
"failure_message"
"metadata"
"metadata.X" where X is a single metadata property
publication"voucher_code"
"customer_id"
"date"
"channel"
"campaign"
"metadata"
"is_winner"
"metadata.X" where X is a single metadata property
customer"name, id"
"description"
"email"
"source_id"
"created_at"
"address_city"
"address_state"
"address_line_1"
"address_line_2"
"address_country"
"address_postal_code"
"metadata"
"metadata.X" where X is a single metadata property
"redemptions_total_redeemed"
"redemptions_total_failed"
"redemptions_total_succeeded"
"redemptions_total_rolled_back"
"redemptions_total_rollback_failed"
"redemptions_total_rollback_succeeded"
"orders_total_amount"
"orders_total_count"
"orders_average_amount"
"orders_last_order_amount"
"orders_last_order_date"
"loyalty_points"
"loyalty_referred_customers"
"updated_at"
"phone"
"birthdate"
points_expiration"id",
"campaign_id",
"voucher_id",
"expires_at",
"points"

Pagination and example request

Voucherify allows you to specify the timeframe for the records you want to retrieve. Thanks to this mechanism it should easy to implement a pagination mechanism. See the example of request body:

{
   "exported_object":"redemption",
   "parameters":{
      "order":"-created_at", // results start from the latest resources, "created_at" sorts from the oldest to the newest resources
      "fields":[
         "id",
         "object",
         "date",
         "voucher_code",
         "customer_id",
         "result"
      ],
      "filters":{
         "junction":"and",
         "created_at":{
            "conditions":{
               "$after":[
                  "2018-05-30T22:00:00.000Z"
               ],
               "$before":[
                  "2018-06-29T22:00:00.000Z"
               ]
            }
         }
      }
   }
}

An export request will almost always result in a single file being generated by the system. However, in the case when your volume of data is large, the system can split the results into multiple chunks.

Response schema

AttributesDescriptionExample
id-exp_8A4J1QLYeBrZsa7XNs1OZBpj
created_at-2017-02-24T13:10:50Z
statusSCHEDULED, DONE, or ERRORDONE
channelInfo how the export was triggered. Returns the channel that was used to generate the particular export.API
exported_objectvoucher, redemption, customer or publicationvoucher
parametersDefines fields and filters for retrieved objects { "fields": [ "code", "voucher_type" ], "filters": { "categories": { "conditions": { "$in": [ "postman" ] } } } }
resultURL to a CSV file{ "url": "https://s3-eu-west-1.amazonaws.com/voucherify-exports/mike%40voucherify.io/export_moGIxqMuCYxLNUJFviiJ8uVA.csv" }
user_idIdentifies the specific user who initiated the export through the Voucherify Dashboard; this user_id is returned when the channel value is WEBSITE.user_g24UoRO3Caxu7FCT4n5tpYEa3zUG0FrH