Webhook
ELI5 — The Vibe Check
A way for one app to automatically notify another when something happens. Instead of constantly asking 'did anything change?' (polling), the app just TELLS you when something happens. Like getting a text notification instead of refreshing your inbox every 5 seconds. Stripe sends webhooks when payments succeed, GitHub sends them when code is pushed.
Real Talk
A webhook is an HTTP callback that delivers real-time notifications from one system to another when an event occurs. The source system sends an HTTP POST request to a pre-configured URL with event data. Webhooks are the foundation of event-driven integrations and are more efficient than polling.
Show Me The Code
// Express webhook endpoint for Stripe
app.post('/webhook/stripe', (req, res) => {
const event = req.body
switch (event.type) {
case 'payment_intent.succeeded':
handlePaymentSuccess(event.data.object)
break
case 'customer.subscription.deleted':
handleCancellation(event.data.object)
break
}
res.json({ received: true })
})
When You'll Hear This
"Set up a webhook so we get notified when a payment succeeds." / "The webhook is failing — check if the endpoint is returning 200."
Related Terms
API (Application Programming Interface)
An API is like a menu at a restaurant. The kitchen (server) can do a bunch of things, but you can only order what's on the menu.
Event-driven
Event-driven architecture means services react to things that happen instead of constantly asking 'did anything change?
HTTP (HyperText Transfer Protocol)
HTTP is the language your browser uses to ask websites for stuff. You type a URL, your browser shouts 'hey, give me that page!
Pub/Sub (Pub/Sub)
Pub/Sub is like a newspaper service. Publishers write articles and drop them off.