failover.io
  1. Home
  2. Guides
  3. Stripe webhooks

How to monitor Stripe webhook health

When your webhook handler stops working, checkouts still succeed and nothing looks broken. A heartbeat tells you within minutes instead of days.

Updated 19 November 20269 min read

When your Stripe webhook handler breaks, checkout keeps working. Stripe still charges the card and still sends the event, but your code never processes it, so the subscription doesn't activate and the order never ships. The first sign is usually a customer asking why they paid for nothing.

Stripe retries a failed delivery with exponential backoff for up to three days in live mode (three times over a few hours in a sandbox), and the Event deliveries tab of your endpoint in Workbench shows each event as Delivered, Pending or Failed. That tab only helps if someone opens it. It also can't see a handler that returns 200 and then fails while processing the event, because from Stripe's side that delivery worked.

The fix is a heartbeat: your handler pings a monitoring URL after it finishes processing an event, and you get an alert when the pings stop. The rest of this page covers where to put the ping, how to deal with quiet hours and a Node example you can paste in.

How Stripe webhooks fail without anyone noticing

A broken web page shows up fast: users complain and your error rate climbs. A broken webhook handler shows nothing, because the traffic is server to server and Stripe's retries cover short outages. A handler can be down for a day before the missing activations add up to something a person notices.

Stripe's own advice makes a handler correct: verify the Stripe-Signature header, return a 2xx quickly before any slow work, process events asynchronously and log event IDs so a duplicate delivery isn't processed twice. None of that tells you when the handler stops working. For that you need something outside your app that expects to hear from it.

Add a heartbeat after each processed event

A normal uptime check calls your server. A heartbeat works the other way: your code calls the monitor to say it did its job. The monitor knows how often to expect that call, and when one doesn't arrive within the interval plus a grace period, it opens an incident.

For a Stripe handler, send the ping after an event has been processed, never when it arrives. A ping on arrival only proves Stripe can reach your URL; a handler that receives every event and then throws on all of them would still look healthy. With the ping at the end of a successful run, a broken handler produces silence, and silence is what the monitor alerts on.

Quiet hours: choose the interval for your traffic

Webhook traffic is uneven. A busy store might process an event every few seconds, while a B2B app can go six hours overnight without one. If you only ping on real events and set a tight interval, a quiet night looks exactly like an outage and you get paged at 4 a.m. because nobody signed up.

ApproachWhat it provesUse it for
Ping after each processed event, long intervalEvents arrive and get processedEndpoints with steady traffic
Ping from a scheduled jobYour service is running and can reach the monitorEndpoints with little or uneven traffic

With pings after each event, set the expected interval a little longer than the longest normal gap between events, then add a grace period. You catch a real outage, but later on a quiet endpoint. With a scheduled job, a small timer in your app pings on a fixed schedule whatever the webhook traffic. That proves the process is up and can reach the monitor; it doesn't prove events are being handled. Many teams run both and keep a log of processed event IDs for the details.

Node and Express example

Create a heartbeat monitor and copy its URL, which looks like https://api.failover.io/heartbeat/<monitor-id>. The endpoint takes POST; a GET returns 404, and a successful POST returns {"received":true}. Then ping it at the end of a successful run, without waiting for the answer, so the monitoring call can't slow down your response to Stripe or break processing:

// The heartbeat URL from your failover.io monitor
const HEARTBEAT = 'https://api.failover.io/heartbeat/<monitor-id>';

app.post('/stripe/webhook',
  express.raw({ type: 'application/json' }),
  async (req, res) => {
    let event;
    try {
      event = stripe.webhooks.constructEvent(
        req.body,
        req.headers['stripe-signature'],
        process.env.STRIPE_WEBHOOK_SECRET
      );
    } catch (err) {
      // bad signature or payload: tell Stripe, don't ping
      return res.status(400).send(`Webhook Error: ${err.message}`);
    }

    // answer Stripe right away, before the slow work
    res.json({ received: true });

    try {
      await handleEvent(event);   // your real processing
      pingHeartbeat();            // only after success
    } catch (err) {
      console.error('webhook processing failed', err);
      // no ping on purpose: a failed run should look like silence
    }
  }
);

// Never throws into the handler. At most one ping every 30 s: heartbeats
// accept up to 120 pings a minute per monitor, and a busy store would pass that.
let lastPing = 0;
function pingHeartbeat() {
  if (Date.now() - lastPing < 30000) return;
  lastPing = Date.now();
  fetch(HEARTBEAT, { method: 'POST' }).catch(() => {});
}

For the scheduled version on a low-traffic endpoint, drop the call in the handler and send the same POST from a cron job, a serverless schedule or a setInterval in a long-running process every few minutes. Set the monitor's expected interval to match. The cron job heartbeat guide has the details on intervals and grace periods.

What a heartbeat catches and what it misses

A heartbeat answers one question: did the webhook pipeline stop? It catches a handler process that's down, a deploy that broke the route, a database that rejects every write and a server nobody can reach. Those are the failures that cost the most and take longest to notice.

It doesn't catch problems with single events: one event type failing while the rest work, partial processing or a bug that runs without errors but does the wrong thing. For those, keep idempotency checks on event IDs, a log of failed events and an eye on the Event deliveries tab. The heartbeat is the alarm for total failure.

Get the alert to someone who's awake

An email that arrives while you sleep leaves the handler broken until morning. This matters more for webhooks than for a website, because nobody else is going to complain first; the monitor's alert is the only signal you get.

On failover.io, create a monitor of type Heartbeat, set the expected interval and grace period, and POST to its URL from your handler. When pings stop for longer than interval plus grace, an incident opens and the monitor's alert chain runs: each step fires after its wait unless someone has acknowledged, and a recovery message goes out once pings come back. The Free plan includes heartbeats and 2-step alert chains with email, Slack, Discord and Telegram. SMS and phone calls start on Pro.

Frequently asked questions

How do I know if my Stripe webhooks are failing?

Open your endpoint in Workbench and check the Event deliveries tab, which lists each event as Delivered, Pending or Failed. To hear about it within minutes, have your handler ping a heartbeat URL after each processed event and alert when the pings stop.

How long does Stripe retry a failed webhook?

In live mode, Stripe retries a failed delivery with exponential backoff for up to three days. In a sandbox it retries three times over a few hours.

Should the ping happen when the event arrives or after processing?

After processing. A ping on arrival only proves Stripe can reach your URL; a handler that receives every event and then crashes would still look healthy.

What if my webhook traffic is uneven?

Set the expected interval longer than your longest normal quiet period, or ping from a scheduled job. The scheduled ping proves your service is running, not that events are being processed.

Where do I find my Stripe webhook secret?

In Workbench, open the Webhooks tab, select the endpoint and click Reveal secret. It starts with whsec_. When you test with the Stripe CLI, stripe listen prints a different secret.