PlaybooksBatch Downloads with Webhooks
Build a webhook receiver
Receive the result of each job on your server.
HuntAPI sends a JSON body to your endpoint with id (the job), status and, when status is CompletedJob, result.response (the file URL); when it is Error, error holds the reason.
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route("/webhooks/huntapi", methods=["POST"])
def huntapi_webhook():
payload = request.get_json()
status = payload.get("status")
print(f"Webhook received - Job: {payload.get('id')}, Status: {status}")
if status == "CompletedJob":
# Trigger your download or further processing here
print(f" Download URL: {payload['result']['response']}")
else:
print(f" Error: {payload.get('error')}")
return jsonify({"received": True}), 200
if __name__ == "__main__":
app.run(port=3000)