---
title: "Webhooks Listener Example"
description: "This guide shows you how to spin up a minimal local server that can receive AgentSync webhooks."
url: "https://developer.agentsync.io/webhooks-listener-example"
image: "https://developer.agentsync.io/_og/d/c_Ocean.takumi,title_Webhooks+Listener+Example,description_This+guide+shows+you+how+to+spin+up+a+minimal+local+server+that+can+receive+AgentSync+webhooks.,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiMxODdFRkYifX19,p_Ii93ZWJob29rcy1saXN0ZW5lci1leGFtcGxlIg,s_BdHOTGQa9AKsLXdl.png"
---

# 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](#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](#prerequisites)

-   **Python 3.8+** installed locally (check with `python3 --version`)
-   **Pip** for dependency management (comes with most Python installs)

## [Overview](#overview)

In this guide, you will:

1.  Install Svix CLI
2.  Create a Project Folder and Server File
3.  Run the Python example server locally
4.  Use `svix listen` to tunnel a public endpoint
5.  Register that endpoint in the portal
6.  Send a test event and confirm receipt

---

## [1\. Install the Svix CLI](#_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.

```bash
brew install svix/svix/svix-cli
```

(For other install options, see the [Svix CLI](https://docs.svix.com/tutorials/cli) docs.)

## [2\. Create a Project Folder and Server File](#_2-create-a-project-folder-and-server-file)

Pick a folder on your computer where you want to keep this example. For example:

```bash
mkdir webhook-listener
cd webhook-listener
```

Inside the `webhook-listener` folder, create a new file called `app.py` and paste in the following code:

```python
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](#_3-run-the-example-python-server)

First, install Flask from inside the same folder:

```bash
pip install flask
```

Then start the server:

```bash
python app.py # or python3 app.py, depending on your environment
```

If everything worked, your terminal will show something like:

```bash
 * Debug mode: on
 * Running on http://127.0.0.1:3000
```

## [4\. Open a Public Test Endpoint (Svix Tunnel)](#_4-open-a-public-test-endpoint-svix-tunnel)

Since AgentSync needs to reach your server from the internet, use Svix to tunnel requests:

```bash
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:

```bash
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](#_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 `producersync` events
-   Click **Create**

## [6\. Send a Test Event](#_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:

```bash
📩 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](#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](https://developer.agentsync.io/webhooks-quick-start-guide))

> This example is not production ready — it’s intended only for testing and validation.