IntegrationsIntermediate

How to Connect a Webhook to Receive Events

Stand up an endpoint, register it with a service, and confirm real events arrive so two systems can talk in real time.

10 minIntermediate

A webhook lets one service push an event to yours the moment it happens, no polling required. To use one you need an endpoint that accepts a POST, a registration on the sending side, and a way to confirm events land. This guide wires all three.

What you need

  • A service that can send webhooks (payments, forms, a repo host)
  • Somewhere to run a small endpoint, or a tunneling tool for local testing
  • About 12 minutes

Step 1: Expose an endpoint

Create a route that accepts a POST and returns a 200 quickly. The sender only cares that you acknowledge fast; do the heavy work afterward.

server.js
app.post('/webhooks/incoming', (req, res) => {
  res.sendStatus(200);        // acknowledge immediately
  queue.add('handle', req.body); // process out of band
});

Step 2: Make it reachable

For local testing, a tunnel gives the outside world a public URL that forwards to your machine. In production, use your deployed domain instead.

zsh - tunnel
$npx localtunnel --port 3000
your url is: https://calm-otter-12.loca.lt
Use this URL plus your route path when registering
$

Step 3: Register the URL

In the sending service's dashboard, add your full endpoint URL and pick which events to receive. Subscribe only to the events you actually handle.

Dashboard - add webhook
Webhooks > Add endpoint
URL: https://calm-otter-12.loca.lt/webhooks/incoming
Events: order.created, order.refunded
[ Save endpoint ]
Register the URL and select specific events.

Step 4: Verify the signature

Most services sign each payload. Check the signature header against your secret so you only trust events that truly came from the sender.

Never trust an unsigned payload
Your endpoint is public, so anyone could POST to it. Always validate the signature before you act on a webhook, and reject anything that fails.

Result: real events flow into your system the instant they occur, acknowledged fast and verified as genuine before you process them.

Watch related tutorials

Tags
#webhook#integration#events#endpoint#api