Skip to content

Instantly share code, notes, and snippets.

@erickolivares
Created March 20, 2026 04:48
Show Gist options
  • Select an option

  • Save erickolivares/108d635be7ca270efa02ec8cca808666 to your computer and use it in GitHub Desktop.

Select an option

Save erickolivares/108d635be7ca270efa02ec8cca808666 to your computer and use it in GitHub Desktop.
Deletes Content from SailThru API by URL
import hashlib
import json
import requests
import sys
if len(sys.argv) < 2:
print("❌ Usage:")
print("python3 delete-sailthru-content-post.py <id_or_url>")
sys.exit(1)
content_id = sys.argv[1]
with open("credentials-prod.json") as f:
creds = json.load(f)
API_KEY = creds["API_KEY"]
SECRET = creds["SECRET"]
# If you want URL auto-detection, uncomment this block:
# if content_id.startswith("http://") or content_id.startswith("https://"):
# payload = {"url": content_id}
# else:
# payload = {"id": content_id}
payload = {"id": content_id}
format_type = "json"
json_str = json.dumps(payload, separators=(",", ":"))
sig_str = SECRET + API_KEY + format_type + json_str
sig = hashlib.md5(sig_str.encode("utf-8")).hexdigest()
params = {
"api_key": API_KEY,
"format": format_type,
"json": json_str,
"sig": sig,
}
response = requests.delete("https://api.sailthru.com/content", params=params)
print("\n--- Sailthru Response ---")
print("Input:", content_id)
print("Status:", response.status_code)
print("URL:", response.url)
try:
res_json = response.json()
print(json.dumps(res_json, indent=2))
except json.JSONDecodeError:
print("⚠️ Could not parse JSON response")
print(response.text)
print("\n--------------------------\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment