Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Created December 16, 2020 13:17
Show Gist options
  • Save peterjaap/12f37d43cf020c051a7271ac632bdce0 to your computer and use it in GitHub Desktop.
Save peterjaap/12f37d43cf020c051a7271ac632bdce0 to your computer and use it in GitHub Desktop.
Purge Imgix through bash function

Put this in your ~/.zshrc. Be sure to have your API token in IMGIX_API_TOKEN;

export IMGIX_API_TOKEN=yourtokenhere
purge() {
  URL=$1
  echo "Purging ${URL}"
  curl -X POST 'https://api.imgix.com/api/v1/purge' \
    --header 'Authorization: Bearer $BEARER' \
    --header 'Content-Type: application/vnd.api+json' -d "{
    \"data\": {
       \"attributes\": {
        \"url\": \"${URL}\"
      },
      \"type\": \"purges\"
    }
  }"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment