Skip to content

Instantly share code, notes, and snippets.

@cadams500
Created September 8, 2025 18:10
Show Gist options
  • Select an option

  • Save cadams500/ff5b639d0df0f13a4a3de9b28074d588 to your computer and use it in GitHub Desktop.

Select an option

Save cadams500/ff5b639d0df0f13a4a3de9b28074d588 to your computer and use it in GitHub Desktop.
SparkPost Suppression Export Script - Sample
#!/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