How to Receive a Webhook Before You Have a Server

Webhooks invert the usual client-server relationship in a way that causes a specific, recurring headache: instead of your code calling out to fetch data, someone else's system calls you, unprompted, whenever an event happens on their end — a payment succeeds, a file finishes processing, a status changes. To receive that call, you need a publicly reachable URL, running real server code, before you've necessarily built (or deployed) the thing that should handle it.
That creates an awkward ordering problem during development: you want to build and test the webhook handler, but the provider needs a live URL to send to, and your local dev server on localhost:3000 isn't reachable from the internet.
The usual answer: a tunnel
The standard fix is a tunneling tool (ngrok and similar tools are the best-known examples) that exposes your local dev server through a temporary public URL, forwarding real internet traffic down to localhost. Register that temporary URL with the webhook provider, and their real system can now reach your real, unfinished, locally-running code.
This is a genuinely useful tool and solves the "I need a public URL" half of the problem well. It doesn't solve a different, equally common problem: you don't want to wait for the real provider to actually send you an event just to test one specific case. If you're building the handler for "payment failed," you don't want to go find a real test card that triggers a real decline through a real payment provider's sandbox every time you want to re-run that path. You want to send yourself a payload that looks like what the provider would send, on demand, exactly when you want it, without depending on their sandbox environment cooperating.
Two different problems, two different tools
It's worth separating these explicitly, because they're often conflated:
- "I need the outside world to be able to reach my local machine." This is what a tunneling tool solves — useful when you specifically need the real provider's real infrastructure to hit your real, in-progress code, for instance during final integration testing before going live.
- "I need to send myself a realistic webhook payload without depending on a real event happening." This is a mocking problem, not a networking problem, and a tunnel doesn't help with it at all — it just gets a request from A to B faster; it doesn't generate the request.
For most of the actual development work — writing and testing the handler logic itself, checking that a malformed or unexpected payload doesn't crash it, confirming your signature verification correctly rejects a tampered payload — the second problem is the one that matters, and it doesn't require a live tunnel or a real provider account at all.
Testing the handler by treating the provider's format as a spec
A webhook payload is just a JSON body with a documented shape, usually with a handful of known event types, sent as a POST to a URL you registered. Once you have that documented shape, you can reproduce it yourself: define a route that accepts a POST with that structure, and use it to simulate "the provider just sent an event" from your own machine, on demand, for whichever event type you're currently working on — a successful payment, a failed one, a refund, a duplicate delivery (most providers explicitly warn that webhooks can arrive more than once for the same event, so idempotent handling is worth testing directly rather than assuming).
This also happens to be a convenient way to develop and demo the other direction — if you're the one building a product that sends webhooks to your customers, standing up a quick endpoint that logs (or displays, via something like the Request Inspector) exactly what arrived, with what headers and body, is the fastest way to confirm your own outgoing webhook payloads look the way you think they do, before a customer's integration team tells you otherwise.
The tunnel and the mock aren't competing solutions — they answer different questions. One gets a real event to your real code. The other lets you generate the event yourself, so testing a specific case doesn't depend on convincing someone else's system to produce it on cue.
Xerat02
Building MockBase.
More from the blog

CORS Is Not About Your Server. That's Why It's Confusing.
curl works. Postman works. The exact same request from your browser gets blocked — and the confusing part is that the block is enforced by the browser, not the server, which is why the usual debugging instincts don't apply.

Mocking Stripe's Webhooks Without Stripe
A naive webhook mock will always fail your own signature check — Stripe, Twilio, and GitHub each sign their payloads, and a mock that doesn't know the algorithm can only test half the problem.