Skip to main content

Exporting transactions

Contents

Overview

Export transaction (basket) records from Spaaza, including item-level data, totals, and associated customer information.

To create a transaction export, send a POST /tasks request to the Services API with target.export_index set to "transactions". See the Tasks API reference for full endpoint documentation.

Version-specific information

VersionChange details
N/AN/A

Permissions and Authentication

Transaction 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 transactions)

Create an unfiltered CSV export of all transactions 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 transactions export",
"target": {
"action": "export",
"export_index": "transactions",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z"
}
}'

Filtered export: transactions from the last 24 hours

Use a relative_less_than rule on the timestamp field to export only recent transactions:

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": "Transactions from the last 24 hours",
"target": {
"action": "export",
"export_index": "transactions",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "transactions",
"join": "all",
"chain_id": YOUR_CHAIN_ID,
"rules": [
{
"field_name": "timestamp",
"field_type": "date",
"operator": "relative_less_than",
"time_factor": "day",
"time_amount": 1
}
]
}
}
}'

Filtered export: transactions in a specific date range

Use is_between_date with start_date and end_date to export transactions within a bounded time 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": "Transactions for January 2026",
"target": {
"action": "export",
"export_index": "transactions",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "transactions",
"join": "all",
"chain_id": YOUR_CHAIN_ID,
"rules": [
{
"field_name": "timestamp",
"field_type": "date",
"operator": "is_between_date",
"start_date": "2026-01-01T00:00:00Z",
"end_date": "2026-01-31T23:59:59Z"
}
]
}
}
}'

Chunking large exports

If a full transaction export fails due to time limits (e.g. context deadline exceeded), break the export into smaller date windows. A common approach is to export one month at a time:

  1. Determine the date range you need to cover.
  2. Create one export task per month using is_between_date with appropriate start_date and end_date values.
  3. Stagger the trigger.once times so tasks do not all run simultaneously.

For example, to export Q1 2026 in monthly chunks:

Taskstart_dateend_datetrigger.once
12026-01-01T00:00:00Z2026-01-31T23:59:59Z2026-05-26T10:00:00Z
22026-02-01T00:00:00Z2026-02-28T23:59:59Z2026-05-26T10:15:00Z
32026-03-01T00:00:00Z2026-03-31T23:59:59Z2026-05-26T10:30:00Z

Staggering by 10–15 minutes between tasks ensures each has time to complete before the next one starts.

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