Webhooks and cron jobs that fail safely in Next.js: signatures, retries and missed-run alarms A developer behind AI Craftbook detailed how the small Next.js backend on Vercel verifies inbound Resend webhooks using Svix's HMAC-SHA256 signature scheme, checking the raw request body, a five-minute timestamp tolerance, and constant-time comparison to reject forged, tampered, and stale requests. The writeup also covers idempotency keys to prevent duplicate side effects from provider retries, bounded retries and request caps for upstream rate limits, and run logging with gap alarms to catch silently stopped cron jobs. Test output showed valid signatures accepted, tampered and stale payloads rejected, and duplicate deliveries both passing verification. A webhook endpoint is a public URL that does real work when someone posts to it. A cron job is a function that only does its job if a scheduler remembers to call it. Both fail quietly: a forged request looks like a normal one, a retried delivery looks like a new one, and a cron that stopped running produces no errors at all. This is how we handle those failures in the small Next.js backend behind AI Craftbook, on Vercel. One inbound webhook forwards support email. One weekly cron job checks GitHub for changes to the projects we list. Code was written with Claude Code under our direction. Every output below comes from a test or a script we ran. Known gaps in our code are called out where they come up. | Failure | What it looks like | Defence | |---|---|---| | Forged request | Anyone who finds the URL posts a payload | Signature check on the raw body | | Replay | A captured, validly signed request is sent again later | Timestamp inside the signature, short tolerance | | Provider retry | The same event arrives twice; side effects run twice | Idempotency key per message | | Rate limit | Upstream API answers 403 or 429 mid-run | Bounded retries, conditional requests, a request cap | | Silent cron stop | Nothing runs, so nothing errors | Record each run; alarm on the gap | Our inbound email provider, Resend, signs webhooks with Svix. The Svix manual verification docs https://docs.svix.com/receiving/verifying-payloads/how-manual define the scheme: the signed content is ${svix id}.${svix timestamp}.${body} , the key is the base64 part of a whsec ... secret, the algorithm is HMAC-SHA256, and the svix-signature header holds a space-separated list of versioned signatures such as v1,