Exporting vouchers
Contents
- Overview
- Version-specific information
- Permissions and Authentication
- Basic export (all vouchers)
- Filtered export: vouchers redeemed in the last 24 hours
- Filtered export: vouchers created in a date range
- Filtered export: vouchers expiring soon
- Checking task status and downloading
- Further reading
Overview
Export voucher records from Spaaza, including issuance details, redemption status, expiry dates, and associated campaign information.
To create a voucher export, send a POST /tasks request to the Services API with target.export_index set to "vouchers". See the Tasks API reference for full endpoint documentation.
Voucher exports automatically exclude deleted vouchers.
Version-specific information
| Version | Change details |
|---|---|
| N/A | N/A |
Permissions and Authentication
Voucher exports use the Tasks API endpoints, which require chain-scoped authentication on the Services API. See Permissions and Authentication in the Tasks API reference for details on supported authentication methods.
Basic export (all vouchers)
Create an unfiltered CSV export of all vouchers for your chain:
curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": YOUR_CHAIN_ID,
"desc": "Full vouchers export",
"target": {
"action": "export",
"export_index": "vouchers",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z"
}
}'
Filtered export: vouchers redeemed in the last 24 hours
Use a relative_less_than rule on the date_time_redeemed field:
curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": YOUR_CHAIN_ID,
"desc": "Vouchers redeemed in the last 24 hours",
"target": {
"action": "export",
"export_index": "vouchers",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "vouchers",
"join": "all",
"chain_id": YOUR_CHAIN_ID,
"rules": [
{
"field_name": "date_time_redeemed",
"field_type": "date",
"operator": "relative_less_than",
"time_factor": "day",
"time_amount": 1
}
]
}
}
}'
Filtered export: vouchers created in a date range
Use is_between_date to export vouchers created within a specific window:
curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": YOUR_CHAIN_ID,
"desc": "Vouchers created in March 2026",
"target": {
"action": "export",
"export_index": "vouchers",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "vouchers",
"join": "all",
"chain_id": YOUR_CHAIN_ID,
"rules": [
{
"field_name": "date_time_creation",
"field_type": "date",
"operator": "is_between_date",
"start_date": "2026-03-01T00:00:00Z",
"end_date": "2026-03-31T23:59:59Z"
}
]
}
}
}'
Filtered export: vouchers expiring soon
Export vouchers that will expire within the next 7 days using relative_less_than on the expiry field:
curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": YOUR_CHAIN_ID,
"desc": "Vouchers expiring within 7 days",
"target": {
"action": "export",
"export_index": "vouchers",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "vouchers",
"join": "all",
"chain_id": YOUR_CHAIN_ID,
"rules": [
{
"field_name": "date_time_expiry",
"field_type": "date",
"operator": "relative_less_than",
"time_factor": "day",
"time_amount": 7
}
]
}
}
}'
Checking task status and downloading
After creating the export, poll the task status:
curl 'https://{Services API hostname}/tasks/{TASK_ID}' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET'
When the task state is DONE, request the download URL:
curl 'https://{Services API hostname}/tasks/{TASK_ID}/download_url' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET'
Download the file promptly — the URL expires after approximately one hour.
See Get a task and Get download URL for full endpoint details.
Further reading
- Segment filter reference — Full list of operators and field types for filtering
- Tasks API reference — Complete endpoint documentation