Webhooks Listener Example
This guide shows you how to spin up a minimal local server that can receive AgentSync webhooks.
It’s designed for testing and validation before you deploy your own production endpoint.
When to Use This
- You don’t have a webhook endpoint yet but want to test quickly.
- You want to see webhook payloads in your logs before wiring them into your application.
- You’re troubleshooting delivery issues and need to confirm events are reaching you.
Prerequisites
- Python 3.8+ installed locally (check with
python3 --version) - Pip for dependency management (comes with most Python installs)
Overview
In this guide, you will:
- Install Svix CLI
- Create a Project Folder and Server File
- Run the Python example server locally
- Use
svix listento tunnel a public endpoint - Register that endpoint in the portal
- Send a test event and confirm receipt
1. Install the Svix CLI
To send AgentSync test events to your local server, we recommend using the Svix CLI. The Svix CLI allows you to open a public test endpoint that forwards requests to your local server.
brew install svix/svix/svix-cli
(For other install options, see the Svix CLI docs.)
2. Create a Project Folder and Server File
Pick a folder on your computer where you want to keep this example. For example:
mkdir webhook-listener
cd webhook-listener
Inside the webhook-listener folder, create a new file called app.py and paste in the following code:
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/webhook", methods=["POST"])
def webhook_listener():
payload = request.get_json()
if payload is None:
print("❌ Could not parse JSON payload")
return jsonify({"status": "bad request"}), 400
print("📩 Event received:", payload)
return jsonify({"status": "ok"}), 200
if __name__ == "__main__":
app.run(port=3000, debug=True)
This is a tiny Flask server. It listens for webhooks events at: http://localhost:3000/webhook
3. Run the Example Python Server
First, install Flask from inside the same folder:
pip install flask
Then start the server:
python app.py # or python3 app.py, depending on your environment
If everything worked, your terminal will show something like:
* Debug mode: on
* Running on http://127.0.0.1:3000
4. Open a Public Test Endpoint (Svix Tunnel)
Since AgentSync needs to reach your server from the internet, use Svix to tunnel requests:
svix listen http://localhost:3000/webhook
This will:
- Open a public test URL (e.g.,
https://play.svix.com/in/xyz123/) - Forward all incoming requests to your local server
Example output:
Webhook Relay is now listening at:
https://play.svix.com/in/xyz123/
All requests on this endpoint will be forwarded to your local URL:
http://localhost:3000/webhook
View logs and debug information at:
https://play.svix.com/view/xyz123/
5. Register the Endpoint in the AgentSync Portal
- Log into the AgentSync Webhook Portal (contact Support if you don’t have access).
- Use the public Svix URL (
https://play.svix.com/in/xyz123/) as your endpoint URL - Subscribe to one, two or all three
producersyncevents - Click Create
6. Send a Test Event
In the portal, navigate to the Testing tab and send a sample event.
If successful, you’ll see something like this in your terminal:
📩 Event received: {
"data": { "id": "evt_123", ... },
"id": "evt_123",
"type": "producersync.updates_available",
"timestamp": "2025-07-24T22:51:05.206Z"
}
You can also view test delivery logs directly in the Svix dashboard URL printed in Step 4.
Next Steps
Once you’ve confirmed you can receive events locally:
- Replace the example server with your own application endpoint
- Add signature verification and retry handling (see Webhooks Quick Start Guide)
⚠️ This example is not production ready — it’s intended only for testing and validation.