Created
September 8, 2025 18:10
-
-
Save cadams500/ff5b639d0df0f13a4a3de9b28074d588 to your computer and use it in GitHub Desktop.
SparkPost Suppression Export Script - Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| API_KEY='replace-with-your-api-key' | |
| CURSOR='initial' | |
| # Create CSV header | |
| echo "recipient,source,description,created,updated" > suppressions.csv | |
| # Loop through pages | |
| while [ "$CURSOR" != "null" ]; do | |
| RESPONSE=$(curl -s -H "Authorization: $API_KEY" "https://api.sparkpost.com/api/v1/suppression-list?cursor=$CURSOR&per_page=10000") | |
| # Append results to CSV | |
| echo "$RESPONSE" | jq -r '.results[] | [.recipient, .source, .description, .created, .updated] | @csv' >> suppressions.csv | |
| # Get next cursor | |
| CURSOR=$(echo "$RESPONSE" | jq -r '(.links[] | select(.rel=="next") | .href | split("cursor=")[1] | split("&")[0]) // "null"') | |
| done | |
| echo "Export complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment