/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 itsstatus
- trigger a CSV file generation, change the status to
SCHEDULED
- when the generation is over, store the file in S3 and change the
status
toDONE
(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.
Object | Fields |
---|---|
| "code" |
| "object" |
| "voucher_code" |
| "name, id" |
points_expiration | "id", |
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
Attributes | Description | Example |
---|---|---|
id |
| |
created_at | 2017-02-24T13:10:50Z | |
status |
|
|
channel | Info how the export was triggered |
|
exported_object |
|
|
parameters | Defines |
|
result | URL to a CSV file |
|