<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bohdan Hryshchenko</title>
    <description>The latest articles on DEV Community by Bohdan Hryshchenko (@bgr11n).</description>
    <link>https://dev.to/bgr11n</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4256068%2F4dd7830a-e226-4dd6-8888-fd0270908080.jpg</url>
      <title>DEV Community: Bohdan Hryshchenko</title>
      <link>https://dev.to/bgr11n</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bgr11n"/>
    <language>en</language>
    <item>
      <title>How to Test Webhooks Locally with Node.js</title>
      <dc:creator>Bohdan Hryshchenko</dc:creator>
      <pubDate>Fri, 20 Nov 2026 16:39:34 +0000</pubDate>
      <link>https://dev.to/bgr11n/how-to-test-webhooks-locally-with-nodejs-20ok</link>
      <guid>https://dev.to/bgr11n/how-to-test-webhooks-locally-with-nodejs-20ok</guid>
      <description>&lt;p&gt;Your webhook handler is &lt;code&gt;http://localhost:3000&lt;/code&gt;, and Stripe or GitHub can't reach it. So you deploy every change, or run a tunnel and keep updating its URL, and when a request fails you ask the sender for another event and hope it looks the same. Fixing a bug with five small changes in ten minutes gets tiring fast this way.&lt;/p&gt;

&lt;p&gt;In this tutorial you'll build a small Node.js webhook receiver and send it an &lt;code&gt;order.created&lt;/code&gt; event with Hookspot. One of the orders has a total of &lt;code&gt;0&lt;/code&gt;, and the handler rejects it because of a validation bug. You'll find the failed request, fix the check and replay the same request to see that it works.&lt;/p&gt;

&lt;p&gt;You don't need any experience with webhook tools. I ran every step below on my own laptop, and the outputs are copied from those runs, including one mistake I made along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you can't just point a webhook at localhost
&lt;/h2&gt;

&lt;p&gt;A webhook is an HTTP request that another service sends to your app when something happens, for example when an order is placed or someone opens a GitHub issue. The sender needs a public address to send it to, and &lt;code&gt;http://localhost:3000&lt;/code&gt; only exists on your own machine. Stripe or GitHub can't reach it.&lt;/p&gt;

&lt;p&gt;You could deploy every change to a server, or run a tunnel and keep updating its URL. Both work. Both also get tiring fast when you're fixing a bug and want to try five small changes in ten minutes. With Hookspot the flow looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The sender posts to your Hookspot &lt;strong&gt;Webhook URL&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Hookspot stores the request and answers the sender.&lt;/li&gt;
&lt;li&gt;The Hookspot CLI on your laptop receives the request and forwards it to your app.&lt;/li&gt;
&lt;li&gt;Hookspot records what your app answered.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hookspot keeps every request, so you can open it later and send it to your app again as often as you want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You'll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js 22 or newer. Check with &lt;code&gt;node -v&lt;/code&gt;. I tested this tutorial with Node.js v24.14.0.&lt;/li&gt;
&lt;li&gt;A Hookspot account. Everything here works on the &lt;a href="https://hookspot.dev/pricing/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;Free plan&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The Hookspot CLI, installed with npm:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -g @hookspot/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Three terminal windows: one for your app, one for the Hookspot CLI and one for sending test requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The receiver only uses Node's built-in &lt;code&gt;http&lt;/code&gt; module, so the app itself has no npm dependencies.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On Windows, I'd use Git Bash so the commands work as written. My first &lt;code&gt;cd&lt;/code&gt; failed because I pasted a path with backslashes from File Explorer. Git Bash wants forward slashes, so &lt;code&gt;C:\Users\you\Documents&lt;/code&gt; becomes &lt;code&gt;/c/Users/you/Documents&lt;/code&gt;. PowerShell also works, but two commands are different there, and I've noted them below.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1: Create a route in Hookspot
&lt;/h2&gt;

&lt;p&gt;Sign in to the &lt;a href="https://app.hookspot.dev?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;Hookspot dashboard&lt;/a&gt;. The &lt;strong&gt;Overview&lt;/strong&gt; page has a short checklist with four setup steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Create source&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Give it a name, for example &lt;code&gt;Node orders demo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Path in your local app&lt;/strong&gt; to &lt;code&gt;/webhooks/orders&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create route&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open the new route on the &lt;strong&gt;Routes&lt;/strong&gt; board and copy its &lt;strong&gt;Webhook URL&lt;/strong&gt;. With a real provider, this is the URL you'd paste into its webhook settings.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep your Webhook URL private, because anyone who has it can send requests to your app. Leave it out of screenshots, logs and version control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now log in from the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hookspot login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI opens your browser and prints a short code. If the code in the browser matches, click &lt;strong&gt;Approve login&lt;/strong&gt;. The terminal then shows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✓ Logged in as you@example.com
✓ Active project set to Test1 | Default project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Build a small Node.js webhook receiver
&lt;/h2&gt;

&lt;p&gt;Create a folder for the example and open it in all three terminals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir hookspot-node-example
&lt;span class="nb"&gt;cd&lt;/span&gt; hookspot-node-example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this as &lt;code&gt;receiver.js&lt;/code&gt;. It accepts &lt;code&gt;order.created&lt;/code&gt; events on &lt;code&gt;/webhooks/orders&lt;/code&gt;, checks that each order has an ID and a total, and logs the result. I left a bug in the total check on purpose, so don't fix it yet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'node:http'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'content-type'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'application/json'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${JSON.stringify(value)}\n`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleOrderWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'http://localhost'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'POST'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'/webhooks/orders'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not found'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setEncoding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'utf8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;rawBody&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;rawBody&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`400 request body error: ${error.message}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'could not read request body'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rawBody&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'400 invalid JSON'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'invalid JSON'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'order.created'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`422 unsupported event: ${String(event?.type)}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;422&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'unsupported event type'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Intentional bug: zero is valid, but this check treats it as missing.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`422 order.created ${String(orderId)}: id and total are required`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;422&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'id and total are required'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`200 order.created ${orderId} total=${total}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;sendJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;received&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createAppServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handleOrderWebhook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;createAppServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Listening on http://localhost:${PORT}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createAppServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You won't need the &lt;code&gt;createAppServer()&lt;/code&gt; export in this article. The &lt;a href="https://hookspot.dev/blog/webhook-regression-test/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;regression test tutorial&lt;/a&gt; uses it to start the same handler inside a test.&lt;/p&gt;

&lt;p&gt;Next, create two test orders. The first one is an ordinary order:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;order-created.json&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"order.created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ord_test_123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USD"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second has a total of &lt;code&gt;0&lt;/code&gt;, like a fully discounted order or a free trial. That's a valid order, and your app should accept it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;order-created-zero.json&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"order.created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ord_test_zero"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USD"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both files use made-up data. With a real provider you'd use its payload format instead.&lt;/p&gt;

&lt;p&gt;Before going on, run &lt;code&gt;ls&lt;/code&gt; and check that all three files are in the folder. The first time, I skipped saving &lt;code&gt;receiver.js&lt;/code&gt; and got &lt;code&gt;Error: Cannot find module&lt;/code&gt; when I tried to start it. Not a hard fix, but a confusing first error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Start the receiver and the Hookspot CLI
&lt;/h2&gt;

&lt;p&gt;In the &lt;strong&gt;first terminal&lt;/strong&gt;, start the app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node receiver.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Listening on http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;strong&gt;second terminal&lt;/strong&gt;, start the CLI and forward to your app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hookspot listen --forward-to http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI switches to a full-screen view and shows where it will send requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node orders demo
  → http://localhost:3000/webhooks/orders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You didn't type &lt;code&gt;/webhooks/orders&lt;/code&gt; anywhere. The CLI takes the path from your route and adds it for you, so if you put it in &lt;code&gt;--forward-to&lt;/code&gt; too, it appears in the address twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Send your first webhook
&lt;/h2&gt;

&lt;p&gt;In the &lt;strong&gt;third terminal&lt;/strong&gt;, put your Webhook URL in a variable so you don't have to paste it into every command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;WEBHOOK_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'paste your webhook URL here'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then send the normal order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl --request POST \
  --header &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
  --data-binary @order-created.json \
  &lt;span class="s2"&gt;"$WEBHOOK_URL"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt; use &lt;code&gt;$env:WEBHOOK_URL="..."&lt;/code&gt; and then&lt;br&gt;
&lt;code&gt;curl.exe -X POST -H "Content-Type: application/json" --data-binary "@order-created.json" $env:WEBHOOK_URL&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; gets an answer right away:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"status":"ok","request_id":"req_..."}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This answer comes from Hookspot. It means Hookspot received and stored the request, and it says nothing yet about your app. Keep that in mind when debugging, because a sender can report success while your handler failed. I go into this more in a separate article on &lt;a href="https://hookspot.dev/blog/webhook-returns-200-but-app-fails/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;why a webhook returns 200 OK but your app still fails&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To see what your app did with it, look at the &lt;strong&gt;first terminal&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200 order.created ord_test_123 total=4200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI lists the same request together with your app's response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmj4uqg9mvmug8p15nwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxmj4uqg9mvmug8p15nwz.png" alt="Hookspot CLI showing request #1 to /webhooks/orders with 200 OK from localhost:3000" width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the dashboard, open &lt;strong&gt;Requests&lt;/strong&gt; and click the new row. The &lt;strong&gt;What happened&lt;/strong&gt; panel shows that the request was received, routed to one route and delivered with &lt;code&gt;200&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0fv6djsp0rul89n2dx7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0fv6djsp0rul89n2dx7r.png" alt="Hookspot dashboard request detail: Received, Routed to 1 route, Delivered 200 in 13 ms" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Find a failing webhook request
&lt;/h2&gt;

&lt;p&gt;Send the zero-total order from the third terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl --request POST \
  --header &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
  --data-binary @order-created-zero.json \
  &lt;span class="s2"&gt;"$WEBHOOK_URL"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; gets the same &lt;code&gt;"status":"ok"&lt;/code&gt; answer from Hookspot, but your app rejects the order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;422 order.created ord_test_zero: id and total are required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The new request shows up in the CLI with &lt;code&gt;422 Unprocessable Entity&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frac9hy4r8ub4d1383dwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frac9hy4r8ub4d1383dwy.png" alt="Hookspot CLI showing request #2 failed with 422 Unprocessable Entity" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to the error, the total is missing. To check what was actually sent, select the request with &lt;code&gt;↑&lt;/code&gt; &lt;code&gt;↓&lt;/code&gt; and press &lt;code&gt;→&lt;/code&gt; to open the &lt;strong&gt;Request&lt;/strong&gt; tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbmuxe6vf44nxcuv2s5kb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbmuxe6vf44nxcuv2s5kb.png" alt="Hookspot CLI Request tab showing the stored body with &amp;quot;total&amp;quot;: 0" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The body has &lt;code&gt;"total": 0&lt;/code&gt;, so the data arrived correctly and the problem is in the handler.&lt;/p&gt;

&lt;p&gt;It comes from this check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In JavaScript, &lt;code&gt;0&lt;/code&gt; is falsy, so &lt;code&gt;!0&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;. The check treats "no total" and "a total of zero" the same way and rejects both.&lt;/p&gt;

&lt;p&gt;I probably wouldn't have thought to test a zero total by hand. Seeing the stored request made the cause obvious within a few seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Fix the validation
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;receiver.js&lt;/code&gt;, delete the &lt;code&gt;Intentional bug&lt;/code&gt; comment and replace the condition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with a type check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
  &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
  &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'number'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero is a number, so the order now passes. A missing total or a total sent as a string still gets rejected.&lt;/p&gt;

&lt;p&gt;Restart the app in the first terminal to load the change. Press &lt;code&gt;Ctrl+C&lt;/code&gt; and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node receiver.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can leave the Hookspot CLI running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Replay the request to confirm the fix
&lt;/h2&gt;

&lt;p&gt;Instead of sending a new order, go back to the CLI, select the failed request #2 and press &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The CLI sends the stored request to your app again, and this time the app accepts it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200 order.created ord_test_zero total=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The replay appears in the list as #3, with a diff of your app's response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#3 ↻ #2  422 → 200  9ms → 13ms  Node orders demo · POST /webhooks/orders
  -   "error": "id and total are required"
  +   "received": true,
  +   "orderId": "ord_test_zero",
  +   "total": 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzk4txs930st56h1m9r6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzk4txs930st56h1m9r6g.png" alt="Hookspot CLI replay diff: request #3 replays #2, status changes from 422 to 200" width="800" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The payload was identical both times, so the change from &lt;code&gt;422&lt;/code&gt; to &lt;code&gt;200&lt;/code&gt; comes from your fix. This diff is my favorite part of the workflow. Without it you'd add a &lt;code&gt;console.log&lt;/code&gt;, trigger the event again and compare the two responses by eye. Here the before and after sit right next to each other.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the dashboard still says Failed
&lt;/h3&gt;

&lt;p&gt;In the dashboard, the zero-total request is still marked &lt;strong&gt;Failed 422&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9ajrhckbdx3ct4qjnlh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9ajrhckbdx3ct4qjnlh6.png" alt="Hookspot dashboard: the original zero-total delivery still shows Failed 422 with a Retry button" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This confused me at first, but it's how replays work: a CLI replay only happens on your machine, and Hookspot doesn't record it as a delivery attempt.&lt;/p&gt;

&lt;p&gt;If you want Hookspot to record a new attempt, use &lt;strong&gt;Retry&lt;/strong&gt; on the delivery in the dashboard. The article on &lt;a href="https://hookspot.dev/blog/recover-webhooks-laptop-offline/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;recovering webhooks that arrived while your laptop was off&lt;/a&gt; uses it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A repeatable way to debug failed webhooks
&lt;/h2&gt;

&lt;p&gt;The same steps work for most webhook bugs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the failed request in the CLI or the dashboard.&lt;/li&gt;
&lt;li&gt;Check the stored body in the &lt;strong&gt;Request&lt;/strong&gt; tab and your app's answer in &lt;strong&gt;Response&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Fix the handler and restart the app.&lt;/li&gt;
&lt;li&gt;Replay the request with &lt;code&gt;r&lt;/code&gt; and look at the diff.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can repeat steps 3 and 4 as many times as you need without asking the sender for another event.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you use this with real orders
&lt;/h2&gt;

&lt;p&gt;This receiver is only meant for local testing. It doesn't verify provider signatures, authenticate requests or limit the body size, and it just logs orders instead of saving them. Please don't ship it as is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;To keep the zero-total request as an automated test, see &lt;a href="https://hookspot.dev/blog/webhook-regression-test/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;Turn a captured webhook into a Node.js regression test&lt;/a&gt;. It exports this request and uses it in a test that fails if someone brings &lt;code&gt;!total&lt;/code&gt; back.&lt;/p&gt;

&lt;p&gt;If webhooks arrived while your listener was stopped, &lt;a href="https://hookspot.dev/blog/recover-webhooks-laptop-offline/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;How to recover webhooks that arrived while your laptop was off&lt;/a&gt; shows how to retry them. &lt;a href="https://hookspot.dev/blog/test-github-webhooks-locally-nodejs/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;How to Test GitHub Webhooks Locally with Node.js&lt;/a&gt; uses the same setup with a real GitHub &lt;code&gt;issues.opened&lt;/code&gt; event.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I test webhooks locally without deploying my app?
&lt;/h3&gt;

&lt;p&gt;Yes. The sender posts to your Hookspot URL, and the CLI forwards each request to &lt;code&gt;localhost&lt;/code&gt;, so your app can stay on your laptop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need ngrok or another tunnel?
&lt;/h3&gt;

&lt;p&gt;No. The Hookspot CLI connects your machine to your project, and the Webhook URL stays the same when you restart.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens if my laptop is off when a webhook arrives?
&lt;/h3&gt;

&lt;p&gt;Hookspot stores the request and marks its delivery &lt;strong&gt;Skipped&lt;/strong&gt;. After you start the CLI again, retry it from the dashboard, as described in &lt;a href="https://hookspot.dev/blog/recover-webhooks-laptop-offline/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;How to recover webhooks that arrived while your laptop was off&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does replaying a request count toward my plan's limits?
&lt;/h3&gt;

&lt;p&gt;A CLI replay runs locally and isn't recorded as a delivery attempt. &lt;a href="https://hookspot.dev/docs/plans-and-limits/?utm_source=dev&amp;amp;utm_medium=article&amp;amp;utm_campaign=dev-test-webhooks-locally-nodejs" rel="noopener noreferrer"&gt;Plans and limits&lt;/a&gt; explains which deliveries count.&lt;/p&gt;

</description>
      <category>node</category>
      <category>webhooks</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
