<?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>Forem: Mary Olowu</title>
    <description>The latest articles on Forem by Mary Olowu (@itsmarydan).</description>
    <link>https://forem.com/itsmarydan</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F716762%2F54914207-db14-4bf3-b944-8704ebab0094.jpeg</url>
      <title>Forem: Mary Olowu</title>
      <link>https://forem.com/itsmarydan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/itsmarydan"/>
    <language>en</language>
    <item>
      <title>Add Webhooks to Your SaaS in 10 Minutes (Without Queues or Retries)</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Mon, 04 May 2026 18:50:28 +0000</pubDate>
      <link>https://forem.com/itsmarydan/add-webhooks-to-your-saas-in-10-minutes-without-queues-or-retries-4e5c</link>
      <guid>https://forem.com/itsmarydan/add-webhooks-to-your-saas-in-10-minutes-without-queues-or-retries-4e5c</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; — One API call subscribes a customer endpoint. Centrali signs each delivery with HMAC-SHA256, retries 5 times over ~40 minutes on failure, logs every attempt, and exposes a one-line replay endpoint. No queue. No retry logic. No Svix. The whole subscribe call is right below — scroll to it if you just want the shape.&lt;/p&gt;




&lt;p&gt;Your customers want webhooks. You know the checklist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A queue so user requests don't block on HTTPS calls to third-party servers&lt;/li&gt;
&lt;li&gt;HMAC signing so customers can verify the request came from you&lt;/li&gt;
&lt;li&gt;Retry with exponential backoff, jitter, a max attempt count&lt;/li&gt;
&lt;li&gt;A circuit breaker so flaky endpoints don't cost you compute&lt;/li&gt;
&lt;li&gt;A delivery log with replay for the &lt;em&gt;"we never got that event"&lt;/em&gt; support ticket&lt;/li&gt;
&lt;li&gt;A subscription model with rotatable secrets, event filters, active/inactive state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's two weeks of work, plus ongoing maintenance. &lt;strong&gt;This post shows how to skip all of it.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The whole thing, in one SDK call
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;CentraliSDK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RecordEvents&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@centrali-io/centrali-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;webhookSubscriptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customer-acme-order-events&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://customer-acme.example.com/webhooks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;events&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;RecordEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CREATED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RecordEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;UPDATED&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;recordSlugs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orders&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// `secret` is returned on create only — copy it now, reads omit it.&lt;/span&gt;
&lt;span class="nx"&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Signing secret:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the whole setup. HMAC signing, retry, circuit breaker, delivery log, replay — all behind that one call. The rest of this post explains what just got handled for you, and shows how to wire up the customer side.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you'd build yourself (and won't have to)
&lt;/h2&gt;

&lt;p&gt;Before the tutorial, the honest version of what ships with a production-ready webhook system:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;An outbound queue.&lt;/strong&gt; You can't block the user's API request on an HTTPS call to a customer server. Something has to pull from a queue (Redis, SQS, BullMQ) and dispatch asynchronously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HMAC signing.&lt;/strong&gt; Sign the raw body with the subscription's secret, attach as a header. Secrets must be rotatable and scoped per subscription.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retry with backoff.&lt;/strong&gt; When a delivery fails (5xx or timeout), retry — but not immediately, and not forever. Exponential backoff is the baseline. Most teams get this subtly wrong: no jitter, too many attempts, too aggressive early.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circuit breaker.&lt;/strong&gt; When a customer's endpoint has been failing for minutes, stop attempting. Resume when it's healthy. Otherwise you waste compute on doomed requests and compound the outage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery log.&lt;/strong&gt; Every attempt: HTTP status, response body, error, timestamp. This is the contract with support. When a customer asks &lt;em&gt;"did you send it?"&lt;/em&gt;, the log is the only answer that matters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual replay.&lt;/strong&gt; Customer deploys a fix, wants to catch up on the last hour. They need a replay endpoint. It shouldn't duplicate into your retry queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A subscription model.&lt;/strong&gt; Customers create subscriptions, scoped to events and record types. Activate/deactivate. Rotate the secret without losing history.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each item is a day of work. Together they're a sprint. Maintained well, they're an ongoing tax on your platform team.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Centrali gives you
&lt;/h2&gt;

&lt;p&gt;One line each, mapped to the list above:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Outbound queue:&lt;/strong&gt; built in, no worker to deploy. Dispatch happens on record changes automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HMAC signing:&lt;/strong&gt; SHA-256 over the raw body, base64-encoded, header is &lt;code&gt;X-Signature&lt;/code&gt;. Secret is &lt;code&gt;whsec_…&lt;/code&gt;, auto-generated per subscription, rotatable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retry with backoff:&lt;/strong&gt; 5 attempts over ~40 minutes — delays of &lt;code&gt;30s&lt;/code&gt;, &lt;code&gt;2m&lt;/code&gt;, &lt;code&gt;10m&lt;/code&gt;, &lt;code&gt;30m&lt;/code&gt; between attempts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circuit breaker:&lt;/strong&gt; per-URL, opens when an endpoint is consistently failing, resets after a cool-down. Flaky endpoints stop costing you compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery log:&lt;/strong&gt; every attempt stored — HTTP status, error, payload, response body — visible in the console and queryable via API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual replay:&lt;/strong&gt; one endpoint — &lt;code&gt;POST /webhook-subscriptions/deliveries/{id}/retry&lt;/code&gt;. New delivery is linked to the original via &lt;code&gt;replayedFrom&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subscription model:&lt;/strong&gt; collection-scoped (via &lt;code&gt;recordSlugs&lt;/code&gt;), event-type-filtered (&lt;code&gt;record_created&lt;/code&gt;, &lt;code&gt;record_updated&lt;/code&gt;, &lt;code&gt;record_deleted&lt;/code&gt;), active/inactive, rotatable secret.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Tutorial: ship an outbound webhook in 5 minutes
&lt;/h2&gt;

&lt;p&gt;The demo: a SaaS that tracks orders. When an order is created or updated, subscribed customers get a webhook.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a collection
&lt;/h3&gt;

&lt;p&gt;If you don't have one already, create an &lt;code&gt;orders&lt;/code&gt; collection in the Centrali console. Any collection works — Centrali emits record events for every collection in the workspace.&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.amazonaws.com%2Fuploads%2Farticles%2Ffzeovma8ip0rmltgbng3.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.amazonaws.com%2Fuploads%2Farticles%2Ffzeovma8ip0rmltgbng3.png" alt="Orders records table with pending, paid, and refunded orders" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Subscribe a customer endpoint
&lt;/h3&gt;

&lt;p&gt;You already saw the subscribe call at the top of the post. The response wraps the subscription under &lt;code&gt;sub.data&lt;/code&gt; — the two fields that matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sub.data.id&lt;/code&gt; — subscription ID for updates and delivery queries&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sub.data.secret&lt;/code&gt; — signing secret, &lt;strong&gt;returned once on create&lt;/strong&gt;. Save it and hand it to your customer so they can verify incoming requests. If lost, rotate in the console: old-secret deliveries stay in the log, new deliveries use the new secret.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The console view shows the subscription with URL, event filters, a masked rotatable secret, signature header, and algorithm:&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.amazonaws.com%2Fuploads%2Farticles%2Fee6shkbz4e4pgq92nvak.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.amazonaws.com%2Fuploads%2Farticles%2Fee6shkbz4e4pgq92nvak.png" alt="Subscription detail view showing URL, events, record filter, signing secret, and signature header" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prefer raw HTTP?&lt;/strong&gt; Same shape over REST — &lt;code&gt;POST /data/workspace/{your-workspace}/api/v1/webhook-subscriptions&lt;/code&gt; with a bearer token and a body matching the SDK call. Translating &lt;code&gt;fetch&lt;/code&gt; or any HTTP client is one-to-one.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 3: Trigger an event
&lt;/h3&gt;

&lt;p&gt;Any record change in the &lt;code&gt;orders&lt;/code&gt; collection now fans out to subscribed endpoints. Create an order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRecord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orders&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;orderNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ORD-1045&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;customerEmail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pia@terradome.studio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;210&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pending&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;itemCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&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;Centrali dispatches a POST to the subscribed URL within seconds. The request body looks like this:&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="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"record_created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"workspaceSlug"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"demo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"recordSlug"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"orders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"recordId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"7d5a87d5-b10c-48bb-85d8-c42dbdaab417"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"orderNumber"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ORD-1045"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"customerEmail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pia@terradome.studio"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;210&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"USD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pending"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"itemCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"placedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-04-22T04:59:00Z"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-04-22T04:59:02Z"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the headers include the HMAC signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X-Signature: xXyHjYrTLS0bKh9qypUv8U5fj5UwBpIn2u0loyEoSQg=
Content-Type: application/json
User-Agent: Centrali-Webhooks/1.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.amazonaws.com%2Fuploads%2Farticles%2Frtfq0wnx5cpvbk0qmyt0.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.amazonaws.com%2Fuploads%2Farticles%2Frtfq0wnx5cpvbk0qmyt0.png" alt="webhook.site showing the request payload and X-Signature header" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Verify the signature on the customer side
&lt;/h3&gt;

&lt;p&gt;The signature is &lt;code&gt;HMAC-SHA256(signingSecret, rawBody)&lt;/code&gt;, base64-encoded. The critical word is &lt;strong&gt;raw&lt;/strong&gt;: compute it over the exact bytes you received, before any JSON parsing or middleware touches them.&lt;/p&gt;

&lt;p&gt;Here's an Express.js handler that does it right:&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;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crypto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;WEBHOOK_SECRET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CENTRALI_WEBHOOK_SECRET&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Use raw body middleware for the webhook route only&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/webhooks/centrali&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-Signature&lt;/span&gt;&lt;span class="dl"&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&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="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;missing signature&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;expected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createHmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WEBHOOK_SECRET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// req.body is a Buffer of the raw bytes&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;base64&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timingSafeEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expected&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invalid signature&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="nx"&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;got event:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;recordId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Do work, then 2xx to acknowledge&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&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="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two gotchas that trip up every first implementation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Parse after verification.&lt;/strong&gt; If you let &lt;code&gt;express.json()&lt;/code&gt; touch the request first, the raw bytes are gone and the signature won't match. Use &lt;code&gt;express.raw()&lt;/code&gt; for this route only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constant-time comparison.&lt;/strong&gt; &lt;code&gt;===&lt;/code&gt; leaks timing information. Use &lt;code&gt;crypto.timingSafeEqual&lt;/code&gt; or your language's equivalent.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Normally you'd be writing the signing code too&lt;/strong&gt; — on your server. Here your server doesn't ship webhook code at all. The only HMAC work is on the customer's end, which is where it belongs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What happens when the customer's endpoint is down
&lt;/h2&gt;

&lt;p&gt;The honest failure mode is what sells the feature. Create a second subscription pointed at a deliberately broken endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;webhookSubscriptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customer-globex-order-events&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://httpbin.org/status/500&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;events&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;RecordEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CREATED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RecordEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;UPDATED&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;recordSlugs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orders&lt;/span&gt;&lt;span class="dl"&gt;'&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;Trigger any order event and watch the delivery log. The first attempt fails with HTTP 500. The next four attempts happen at &lt;code&gt;+30s&lt;/code&gt;, &lt;code&gt;+2m&lt;/code&gt;, &lt;code&gt;+10m&lt;/code&gt;, &lt;code&gt;+30m&lt;/code&gt;. The log stays visible the whole time, with live &lt;code&gt;nextAttemptAt&lt;/code&gt; and &lt;code&gt;attemptCount&lt;/code&gt; values:&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.amazonaws.com%2Fuploads%2Farticles%2Fzt7oou3oitpzhvm4h6di.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.amazonaws.com%2Fuploads%2Farticles%2Fzt7oou3oitpzhvm4h6di.png" alt="Delivery log during retry — record_created and record_updated retrying at attempt 4" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the fifth attempt, the delivery's status flips to &lt;code&gt;failed&lt;/code&gt; and the error is preserved:&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.amazonaws.com%2Fuploads%2Farticles%2Fq0pajrv0wkysgivx9ik9.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.amazonaws.com%2Fuploads%2Farticles%2Fq0pajrv0wkysgivx9ik9.png" alt="Delivery log with failed deliveries after retry exhaustion" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No retry code in your app. No job queue. No alerts you wired up and forgot about. Just a log you point support at when someone asks &lt;em&gt;"did it send?"&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Replay a failed delivery once the endpoint is healthy
&lt;/h2&gt;

&lt;p&gt;The customer fixes their endpoint. They want the missed events. Replay any failed delivery by ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;webhookSubscriptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deliveries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deliveryId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new delivery is created, pointed at the current subscription URL. The new delivery's detail view shows the original delivery ID under &lt;code&gt;replayedFrom&lt;/code&gt; — you always know where a replay came from:&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.amazonaws.com%2Fuploads%2Farticles%2F9n91ucfdgxhwastbz1k9.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.amazonaws.com%2Fuploads%2Farticles%2F9n91ucfdgxhwastbz1k9.png" alt="Delivery detail showing Status Success, HTTP 200, attempts 1, Replayed from: 5a9b39e2-b695-44ba-aaae-be96bd3c4af8" width="800" height="976"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If replay was the entire story, you'd still need a queue. But combined with automatic retry plus the delivery log, the customer flow becomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Customer endpoint goes down.&lt;/li&gt;
&lt;li&gt;Centrali tries for ~40 minutes, then gives up (logged).&lt;/li&gt;
&lt;li&gt;Customer fixes their endpoint.&lt;/li&gt;
&lt;li&gt;Customer (or you, from their support request) hits the replay endpoint once.&lt;/li&gt;
&lt;li&gt;Back to normal — no lost events.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's in the subscription model
&lt;/h2&gt;

&lt;p&gt;If you've used Svix or Hookdeck, this shape will feel familiar:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Display name — usually the customer's name + event scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;url&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HTTPS endpoint that receives deliveries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;events&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Event types to subscribe to — &lt;code&gt;record_created&lt;/code&gt;, &lt;code&gt;record_updated&lt;/code&gt;, &lt;code&gt;record_deleted&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recordSlugs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Collection filter — deliver only for these record slugs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;status&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;active&lt;/code&gt; or &lt;code&gt;inactive&lt;/code&gt; — pause without deleting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;signingSecret&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shared secret for HMAC signing (auto-generated, rotatable)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;signatureHeader&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Header name for the signature (default: &lt;code&gt;X-Signature&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;algorithm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HMAC algorithm (default: &lt;code&gt;sha256&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;encoding&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Signature encoding (default: &lt;code&gt;base64&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One subscription per customer-per-scope. Rotating the secret doesn't lose history — existing deliveries in the log remain readable, future deliveries use the new secret.&lt;/p&gt;

&lt;h2&gt;
  
  
  When you should still build it yourself
&lt;/h2&gt;

&lt;p&gt;If webhooks are core to your product — you're Zapier, or Segment, or you're Svix — you need more than what's in a backend platform. Per-customer delivery portals, detailed per-endpoint SLAs, webhook-as-a-product pricing, platform-wide rate budgets. Those companies exist for a reason and the category is real.&lt;/p&gt;

&lt;p&gt;If webhooks are a feature of your product — one of many things your API does, and your customers want them — you don't need dedicated webhook infrastructure. You need the seven things above, and you need them to work without turning into a team's full-time job.&lt;/p&gt;

&lt;p&gt;That's what the platform you're already using gives you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Follow along:&lt;/strong&gt; &lt;a href="https://centrali.io/signup?utm_source=blog&amp;amp;utm_medium=content&amp;amp;utm_campaign=add-webhooks-to-your-saas" rel="noopener noreferrer"&gt;Create a free workspace&lt;/a&gt; and subscribe your first endpoint in 5 minutes. No deployment required.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://centrali.io/blog/ingest-github-webhooks" rel="noopener noreferrer"&gt;Ingest Webhooks From Any Provider — GitHub as the Example&lt;/a&gt; — the receive side, with signature verification&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://centrali.io/blog/stripe-webhook-handler" rel="noopener noreferrer"&gt;Stripe Webhook Handler&lt;/a&gt; — handle inbound Stripe events end-to-end&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://centrali.io/blog/query-stripe-webhook-events-like-a-database" rel="noopener noreferrer"&gt;Query Stripe Webhook Events Like a Database&lt;/a&gt; — what to do with webhooks once you've received them&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>webdev</category>
      <category>webhooks</category>
      <category>saas</category>
    </item>
    <item>
      <title>What Is Record TTL? Database Time-to-Live Explained</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Tue, 28 Apr 2026 18:22:25 +0000</pubDate>
      <link>https://forem.com/itsmarydan/what-is-record-ttl-database-time-to-live-explained-263c</link>
      <guid>https://forem.com/itsmarydan/what-is-record-ttl-database-time-to-live-explained-263c</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Cross-posted from &lt;a href="https://centrali.io/blog/what-is-record-ttl" rel="noopener noreferrer"&gt;the Centrali blog&lt;/a&gt;.&lt;/strong&gt; The canonical version with code highlighting and updates lives there.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Record TTL (time-to-live) is a database feature that automatically deletes records once they expire. You set an expiration time on a record — by duration ("delete in 1 hour") or by timestamp ("delete on March 1") — and the database removes it without a cron job. This is &lt;em&gt;database&lt;/em&gt; TTL; it's the same idea as DNS TTL but applied to rows in a table instead of cached DNS lookups.&lt;/p&gt;

&lt;p&gt;A note before we go further: if you searched for "TTL" and ended up here looking for &lt;strong&gt;DNS TTL&lt;/strong&gt; (how long a DNS resolver caches an A/AAAA/CNAME record), this isn't that post — try &lt;a href="https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl/" rel="noopener noreferrer"&gt;Cloudflare's DNS TTL reference&lt;/a&gt;. This post is about &lt;strong&gt;record TTL in databases&lt;/strong&gt;: making rows in your data store auto-delete on a schedule.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Record TTL?
&lt;/h2&gt;

&lt;p&gt;Record TTL is a per-record expiration time. The database tracks an &lt;code&gt;expiresAt&lt;/code&gt; timestamp on the record (either set explicitly or computed from a duration), and once that timestamp passes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The record disappears from query results immediately (read-time filtering).&lt;/li&gt;
&lt;li&gt;A background sweep deletes it from storage permanently.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two writes you make as a developer are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ttlSeconds&lt;/code&gt;&lt;/strong&gt; — a duration. &lt;em&gt;"Delete this record 3,600 seconds from now."&lt;/em&gt; The database calculates the absolute &lt;code&gt;expiresAt&lt;/code&gt; for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;expiresAt&lt;/code&gt;&lt;/strong&gt; — an absolute timestamp. &lt;em&gt;"Delete this record at 2026-09-01T00:00:00Z."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both end up storing the same field. Use &lt;code&gt;ttlSeconds&lt;/code&gt; when the deadline is relative ("expire 24 hours after creation"); use &lt;code&gt;expiresAt&lt;/code&gt; when the deadline is fixed ("expire on the sale end date").&lt;/p&gt;

&lt;h2&gt;
  
  
  How TTL Works (Mechanically)
&lt;/h2&gt;

&lt;p&gt;Three things happen between "you wrote a TTL" and "the record is gone":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Write time&lt;/strong&gt; — you create or update a record with &lt;code&gt;ttlSeconds&lt;/code&gt; or &lt;code&gt;expiresAt&lt;/code&gt;. The database stores the absolute expiration timestamp on the record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read time&lt;/strong&gt; — every query is implicitly filtered against &lt;code&gt;now()&lt;/code&gt;. Records past their &lt;code&gt;expiresAt&lt;/code&gt; are excluded from results, even if they haven't been physically deleted yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sweep time&lt;/strong&gt; — a background job (every few minutes, depending on the database) finds expired records and deletes them. Some systems also publish an event ("record.expired") so your app can react before the row is gone.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The key property: &lt;strong&gt;expired records become invisible to your application instantly&lt;/strong&gt;, even if the on-disk delete lags by minutes. You don't need to filter &lt;code&gt;WHERE expiresAt &amp;gt; now()&lt;/code&gt; in every query — the database does it for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use Record TTL
&lt;/h2&gt;

&lt;p&gt;TTL is the right tool whenever you're tempted to write a "cleanup script that runs every night." Common cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Session tokens&lt;/strong&gt; — expire after 24 hours of inactivity, or 30 days from creation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verification codes&lt;/strong&gt; — one-time codes for email verification, magic links, password reset. Expire in 15 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Promo codes and flash deals&lt;/strong&gt; — auto-disable when the deadline hits (or the flash window closes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Draft content&lt;/strong&gt; — autosave drafts that should evaporate after N days unless promoted to a published post.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate-limit windows&lt;/strong&gt; — track requests-per-minute by storing a record per request with a 60-second TTL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit logs with retention rules&lt;/strong&gt; — "delete after 90 days" without writing the cleanup job yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache-like records&lt;/strong&gt; — when you need durable storage with cache-like eviction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The negative test: TTL is the wrong tool when you need &lt;em&gt;soft&lt;/em&gt; expiration — i.e., the record should be flagged as expired but kept around for analytics or recovery. For that, use a status field (&lt;code&gt;status: 'archived'&lt;/code&gt;) and filter explicitly. TTL means &lt;em&gt;gone&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Default TTL vs. Per-Record TTL
&lt;/h2&gt;

&lt;p&gt;Most databases that support record TTL let you set it at two levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Default TTL on the collection (or table)&lt;/strong&gt; — every new record auto-inherits the duration. Set this for collections that are &lt;em&gt;always&lt;/em&gt; time-bounded (sessions, verification codes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-record TTL&lt;/strong&gt; — override the default (or set TTL on a record in a non-TTL collection). Set this for one-off cases — flash promos in a long-lived "Promotions" table, for example.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A reasonable mental model: default TTL is for the table's &lt;em&gt;intent&lt;/em&gt;; per-record TTL is for the &lt;em&gt;exception&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database TTL vs. DNS TTL
&lt;/h2&gt;

&lt;p&gt;Same name, different concept. They share the underlying idea — "this thing is valid for N seconds, then forget it" — but they apply to different layers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;DNS TTL&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Database (record) TTL&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What expires&lt;/td&gt;
&lt;td&gt;A DNS record cached at a resolver&lt;/td&gt;
&lt;td&gt;A row stored in your database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who enforces it&lt;/td&gt;
&lt;td&gt;DNS resolvers worldwide&lt;/td&gt;
&lt;td&gt;Your database server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical duration&lt;/td&gt;
&lt;td&gt;Seconds to hours&lt;/td&gt;
&lt;td&gt;Minutes to months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tunable per-record?&lt;/td&gt;
&lt;td&gt;Yes (per DNS record)&lt;/td&gt;
&lt;td&gt;Yes (per row, if the DB supports it)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What "expired" means&lt;/td&gt;
&lt;td&gt;Resolver re-fetches from authoritative server&lt;/td&gt;
&lt;td&gt;Row is hidden from queries and eventually deleted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you're in the DNS world, TTL is about &lt;em&gt;cache freshness&lt;/em&gt;. In the database world, TTL is about &lt;em&gt;automatic cleanup&lt;/em&gt;. The mechanics aren't connected — your A-record TTL has nothing to do with your sessions table TTL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing Record TTL
&lt;/h2&gt;

&lt;p&gt;Most managed databases now offer some form of record TTL: MongoDB has &lt;code&gt;expireAfterSeconds&lt;/code&gt; indexes; DynamoDB has TTL attributes; Redis has &lt;code&gt;EXPIRE&lt;/code&gt;. The exact API differs, but the shape is the same: a field on the record (or an index on a field) tells the database when to delete.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://centrali.io/" rel="noopener noreferrer"&gt;Centrali&lt;/a&gt;, record TTL is built into the storage layer. You set &lt;code&gt;ttlSeconds&lt;/code&gt; or &lt;code&gt;expiresAt&lt;/code&gt; when creating a record, or set a default at the collection level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;CentraliSDK&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@centrali-io/centrali-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CentraliSDK&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;workspaceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-workspace&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;clientId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CENTRALI_CLIENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;clientSecret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CENTRALI_CLIENT_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Per-record TTL: this verification code expires in 15 minutes&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;centrali&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRecord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;VerificationCodes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user-123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;482910&lt;/span&gt;&lt;span class="dl"&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="na"&gt;ttlSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;900&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a step-by-step walkthrough — sessions with sliding expiration, promo codes with fixed deadlines, draft content with TTL clearing on publish — see the companion post: &lt;a href="https://centrali.io/blog/auto-expire-records-with-centrali-ttl" rel="noopener noreferrer"&gt;How to Auto-Expire Records with Centrali TTL&lt;/a&gt;. Full reference lives in the &lt;a href="https://docs.centrali.io/platform/record-ttl/" rel="noopener noreferrer"&gt;Record TTL docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Centrali sits in a broader category — a backend for ingesting third-party webhooks, storing them as data, and sending your own webhooks and workflows. Record TTL is one feature inside the storage layer; if you're working with &lt;a href="https://centrali.io/blog/stripe-webhook-handler" rel="noopener noreferrer"&gt;stored Stripe webhook events&lt;/a&gt; or &lt;a href="https://centrali.io/blog/schema-discovery-guide" rel="noopener noreferrer"&gt;schemaless data&lt;/a&gt;, the same TTL rules apply to those records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Does TTL delete data immediately when it expires?&lt;/strong&gt;&lt;br&gt;
Records become invisible to queries the instant &lt;code&gt;expiresAt&lt;/code&gt; passes. Physical deletion happens on a background sweep, typically within a few minutes. Don't rely on instant disk deletion for security-sensitive data — use a separate purge if you need it gone &lt;em&gt;now&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I extend a TTL after the record is created?&lt;/strong&gt;&lt;br&gt;
Yes — update the record with a new &lt;code&gt;ttlSeconds&lt;/code&gt; or &lt;code&gt;expiresAt&lt;/code&gt;. This is how "sliding expiration" works for sessions: every authenticated request resets the TTL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I remove a TTL after setting one?&lt;/strong&gt;&lt;br&gt;
Yes — most TTL implementations support clearing the expiration so the record becomes permanent. In Centrali, pass &lt;code&gt;{ clearTtl: true }&lt;/code&gt; on the update.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is TTL the same as data retention policy?&lt;/strong&gt;&lt;br&gt;
TTL is a &lt;em&gt;mechanism&lt;/em&gt; for retention. A retention policy is the &lt;em&gt;rule&lt;/em&gt; ("keep audit logs for 90 days"); TTL is one way to enforce it. Other ways: scheduled jobs, archival to cold storage, manual purges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's the smallest practical TTL?&lt;/strong&gt;&lt;br&gt;
Depends on the database, but seconds-level TTL is common. Sub-second TTL usually doesn't make sense — by the time the write replicates, the record may already be expired.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Record TTL is the database equivalent of "set it and forget it" cleanup: assign an expiration to a record, and the database handles the rest. Use it for any data that's intrinsically time-bounded — sessions, codes, promos, drafts, rate-limit windows. Don't confuse it with DNS TTL; same name, different layer.&lt;/p&gt;

&lt;p&gt;If you want to see TTL in action with concrete code, the &lt;a href="https://centrali.io/blog/auto-expire-records-with-centrali-ttl" rel="noopener noreferrer"&gt;auto-expire records guide&lt;/a&gt; walks through three full use cases.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://centrali.io/blog/what-is-record-ttl" rel="noopener noreferrer"&gt;centrali.io/blog/what-is-record-ttl&lt;/a&gt;. Centrali is the backend for webhooks in and out — ingest third-party webhooks, store them as data, and send your own workflows from one SDK.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Test Stripe Webhooks Locally (Stripe CLI + Replay + Logs)</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Wed, 22 Apr 2026 07:43:19 +0000</pubDate>
      <link>https://forem.com/itsmarydan/how-to-test-stripe-webhooks-locally-stripe-cli-replay-logs-7of</link>
      <guid>https://forem.com/itsmarydan/how-to-test-stripe-webhooks-locally-stripe-cli-replay-logs-7of</guid>
      <description>&lt;p&gt;Most Stripe webhook bugs are not business logic bugs. They are reproducibility bugs. If you can't replay the exact event path in under 30 seconds, debugging takes hours instead of minutes — because every attempt involves refreshing the Stripe Dashboard, re-triggering a test, and squinting at logs to figure out whether your handler ran at all.&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.amazonaws.com%2Fuploads%2Farticles%2F78bmt5bsgqz44xdwmkqg.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.amazonaws.com%2Fuploads%2Farticles%2F78bmt5bsgqz44xdwmkqg.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post walks through the local loop that makes this painless: &lt;strong&gt;forward → trigger → replay → inspect.&lt;/strong&gt; Four steps, one terminal window, no guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The loop, in full
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Terminal 1 — forward Stripe events to your local handler&lt;/span&gt;
stripe listen &lt;span class="nt"&gt;--forward-to&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/api/stripe-webhook"&lt;/span&gt;

&lt;span class="c"&gt;# Terminal 2 — trigger real Stripe test events&lt;/span&gt;
stripe trigger payment_intent.succeeded
stripe trigger charge.failed
stripe trigger invoice.payment_failed

&lt;span class="c"&gt;# When something fails, replay the exact event&lt;/span&gt;
stripe events resend evt_1NfP6Q2eZvKYlo2CsKT4a5oS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole loop. Everything below is how to make it reliable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 — Give your dev webhook its own path
&lt;/h2&gt;

&lt;p&gt;Don't forward Stripe events to your production webhook path. Use a dedicated dev path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;stripe listen &lt;span class="nt"&gt;--forward-to&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000/api/stripe-webhook-dev"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why separate? Because you want to test with lax validation (no signature verification, verbose logging) without loosening your production handler. Keep two paths:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/api/stripe-webhook&lt;/code&gt; — production. Strict signature verification, minimal logs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/stripe-webhook-dev&lt;/code&gt; — dev only. Signature check optional, logs every field.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When &lt;code&gt;stripe listen&lt;/code&gt; starts, it prints a signing secret:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Ready! Your webhook signing secret is whsec_abc123...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy that into your dev environment variable (&lt;code&gt;STRIPE_WEBHOOK_SECRET_DEV&lt;/code&gt;). This is NOT the same as the secret from your Stripe Dashboard — the CLI generates its own. This trips up everyone the first time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 — Trigger real events, not made-up payloads
&lt;/h2&gt;

&lt;p&gt;Do not hand-craft JSON payloads. Stripe's &lt;code&gt;trigger&lt;/code&gt; command sends a real event through your account's test data, which means you're testing against payloads that match production exactly.&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="c"&gt;# Core payment flows&lt;/span&gt;
stripe trigger payment_intent.succeeded
stripe trigger charge.succeeded
stripe trigger charge.failed

&lt;span class="c"&gt;# Subscription lifecycle&lt;/span&gt;
stripe trigger customer.subscription.created
stripe trigger customer.subscription.updated
stripe trigger customer.subscription.deleted

&lt;span class="c"&gt;# Invoice / billing&lt;/span&gt;
stripe trigger invoice.payment_succeeded
stripe trigger invoice.payment_failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each trigger writes a real event to your Stripe test account. That means every event has a real &lt;code&gt;id&lt;/code&gt; (starts with &lt;code&gt;evt_&lt;/code&gt;) that you can replay later.&lt;/p&gt;

&lt;p&gt;Run all the events your handler cares about at least once. Anything you haven't triggered locally is a surprise waiting in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 — Replay the exact event, on demand
&lt;/h2&gt;

&lt;p&gt;This is the step most people skip, and it's where debugging speed compounds. When a test fails, you can replay the exact same event by ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;stripe events resend evt_1NfP6Q2eZvKYlo2CsKT4a5oS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same payload. Same signature. Same timestamp. Your handler sees a byte-for-byte identical request.&lt;/p&gt;

&lt;p&gt;This is gold for two reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Idempotency testing.&lt;/strong&gt; Your handler should be safe to call with the same event ID twice. Replay it five times in a row and confirm you create one record, not five. If you create five, you have a bug.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic debugging.&lt;/strong&gt; When something fails at 2am, you can add a &lt;code&gt;console.log&lt;/code&gt;, restart your server, and replay the same event. No hunting for a new trigger, no hoping you can reproduce the path.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 4 — Validate via logs, not hope
&lt;/h2&gt;

&lt;p&gt;For every event, verify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✓ Your handler returned 200 (Stripe will retry otherwise)&lt;/li&gt;
&lt;li&gt;✓ The event ID was logged&lt;/li&gt;
&lt;li&gt;✓ A record was created (first time)&lt;/li&gt;
&lt;li&gt;✓ A replay was skipped (second time — idempotency)&lt;/li&gt;
&lt;li&gt;✓ Unknown event types no-op safely (don't throw)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A minimal handler that makes this visible:&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;export&lt;/span&gt; &lt;span class="k"&gt;default&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;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;verifySignature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// or skip on dev path&lt;/span&gt;

  &lt;span class="nx"&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="s2"&gt;`[stripe] &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;existing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;findEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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="nx"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&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="s2"&gt;`[stripe] skipped duplicate &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&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="na"&gt;skipped&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="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;payment_intent.succeeded&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;handlePaymentSucceeded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;charge.failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;handleChargeFailed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="nx"&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="s2"&gt;`[stripe] no-op for &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;await&lt;/span&gt; &lt;span class="nf"&gt;recordEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three rules this enforces:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Log the event ID on every call.&lt;/strong&gt; When something goes wrong, the event ID is the only key that connects Stripe's dashboard to your logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Return 200 even for no-ops.&lt;/strong&gt; Stripe retries non-200 responses. A &lt;code&gt;throw&lt;/code&gt; on an unknown event type will get retried for 3 days and fill up your logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make duplicate detection visible.&lt;/strong&gt; When you replay for testing, you want to SEE that the skip branch fired.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pre-production checklist
&lt;/h2&gt;

&lt;p&gt;Before you switch Stripe from your CLI forwarder to your real endpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Every event type you care about has been triggered locally at least once&lt;/li&gt;
&lt;li&gt;[ ] Each one has been &lt;strong&gt;replayed&lt;/strong&gt; and the idempotency branch ran&lt;/li&gt;
&lt;li&gt;[ ] At least one unknown event type was sent — handler returned 200, did not throw&lt;/li&gt;
&lt;li&gt;[ ] Signature verification works in prod mode with the real Dashboard secret (not the CLI secret)&lt;/li&gt;
&lt;li&gt;[ ] Handler returns 200 in under 5 seconds for all event types (Stripe times out at 30s but backs off aggressively if you're slow)&lt;/li&gt;
&lt;li&gt;[ ] Logs include event ID on every line relevant to the event&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this costs
&lt;/h2&gt;

&lt;p&gt;Nothing. The Stripe CLI is free. &lt;code&gt;stripe trigger&lt;/code&gt; uses your test mode data. &lt;code&gt;stripe events resend&lt;/code&gt; uses events you already generated. You don't need a tunnel service (ngrok, localtunnel) — &lt;code&gt;stripe listen&lt;/code&gt; does the forwarding itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to pair this with
&lt;/h2&gt;

&lt;p&gt;If you want stored event history you can query later (replay a 2-week-old event, audit a customer's event sequence, etc.), you need something between Stripe and your handler that logs every event permanently. Stripe's own Events API only goes back 30 days and can't filter by fields you care about.&lt;/p&gt;

&lt;p&gt;Centrali's webhook triggers do this out of the box — every inbound event is stored in a collection you can query later. But the testing loop above works with any handler, framework, or platform. The important part is the loop.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If this was useful, I write more about webhook reliability and Stripe integration patterns. Follow me for more.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>stripe</category>
      <category>webhooks</category>
      <category>nextjs</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Stop Writing Custom Scrapers: Index Static Content into Meilisearch with One Config</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Wed, 22 Apr 2026 07:42:56 +0000</pubDate>
      <link>https://forem.com/itsmarydan/stop-writing-custom-scrapers-index-static-content-into-meilisearch-with-one-config-742</link>
      <guid>https://forem.com/itsmarydan/stop-writing-custom-scrapers-index-static-content-into-meilisearch-with-one-config-742</guid>
      <description>&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.amazonaws.com%2Fuploads%2Farticles%2Fdh6vnn32lqtyp4q5yt3p.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.amazonaws.com%2Fuploads%2Farticles%2Fdh6vnn32lqtyp4q5yt3p.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; — &lt;a href="https://github.com/blueinit/content-mill" rel="noopener noreferrer"&gt;content-mill&lt;/a&gt; is an open-source CLI and library that reads static content — MkDocs sites, markdown directories, JSON files, HTML pages — and indexes it into Meilisearch, driven by a YAML config. You define the document shape; it handles extraction, templating, chunking, and atomic zero-downtime re-indexing. You still tune templates and debug extraction for your own content — that part's on you — but you stop maintaining bespoke scraper code.&lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @centrali-io/content-mill
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;If you've ever tried to make your docs, blog posts, or changelogs searchable with Meilisearch, you know the drill: write a custom scraper, parse the content, transform it into the right shape, push it to an index, and hope you don't break search during re-indexing.&lt;/p&gt;

&lt;p&gt;I got tired of writing that glue code for every project, so I built &lt;strong&gt;content-mill&lt;/strong&gt; — a CLI and library that indexes static content into Meilisearch, driven by a YAML config.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Meilisearch is fantastic for search, but getting your content &lt;em&gt;into&lt;/em&gt; it is surprisingly manual. Every docs site, every changelog, every collection of markdown files needs its own extraction pipeline. And if you want zero-downtime re-indexing? That's more code on top.&lt;/p&gt;

&lt;p&gt;Most existing solutions are either tightly coupled to a specific framework (like DocSearch for Algolia) or expect you to run a full crawler. Lighter-weight options exist — usually ad-hoc scripts people write once per project — but nothing I could find that's reusable across source types and explicit about document shape.&lt;/p&gt;

&lt;h2&gt;
  
  
  What content-mill does
&lt;/h2&gt;

&lt;p&gt;You describe your content sources and the document shape you want in a YAML config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;meili&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:7700&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${MEILI_MASTER_KEY}&lt;/span&gt;

&lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docs&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mkdocs&lt;/span&gt;
    &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./mkdocs.yml&lt;/span&gt;
    &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docs&lt;/span&gt;
    &lt;span class="na"&gt;document&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;primaryKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;id&lt;/span&gt;
      &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slug&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;section&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;nav_section&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;docs"&lt;/span&gt;
      &lt;span class="na"&gt;searchableAttributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;filterableAttributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;section&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @centrali-io/content-mill index &lt;span class="nt"&gt;--config&lt;/span&gt; content-mill.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the config matches your content, re-running is a single command. You'll still spend time tuning templates and sanity-checking extraction (use &lt;code&gt;--dry-run&lt;/code&gt; for that) — but you're not maintaining scraper code anymore. content-mill handles extraction, templating, and atomic index swapping, so search never goes down during re-indexing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four source types, one interface
&lt;/h2&gt;

&lt;p&gt;content-mill ships with adapters for the content formats you're most likely already using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;mkdocs&lt;/code&gt;&lt;/strong&gt; — Reads your &lt;code&gt;mkdocs.yml&lt;/code&gt;, follows the nav tree, and parses each markdown page. You get &lt;code&gt;nav_section&lt;/code&gt; context so you know which part of the docs each page belongs to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;markdown-dir&lt;/code&gt;&lt;/strong&gt; — Recursively reads &lt;code&gt;.md&lt;/code&gt; files from a directory. Supports YAML frontmatter, so you can pull version numbers, dates, or any metadata into your search index. Great for changelogs and blog posts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;json&lt;/code&gt;&lt;/strong&gt; — Reads a JSON array (or directory of JSON files). Every key in each object becomes a template variable. Perfect for structured data you already have lying around.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;html&lt;/code&gt;&lt;/strong&gt; — Reads &lt;code&gt;.html&lt;/code&gt; files, strips scripts/styles/nav/footer, and gives you clean text. Useful for indexing a built static site.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Templating: you control the document shape
&lt;/h2&gt;

&lt;p&gt;The key design decision is that &lt;strong&gt;you&lt;/strong&gt; define what your Meilisearch documents look like. Source adapters extract raw variables (&lt;code&gt;slug&lt;/code&gt;, &lt;code&gt;heading&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, &lt;code&gt;path&lt;/code&gt;, &lt;code&gt;frontmatter.*&lt;/code&gt;, etc.), and you map them to fields using &lt;code&gt;{{ template }}&lt;/code&gt; syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slug&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}-{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_index&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;excerpt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;truncate(200)&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}#{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slugify&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filters like &lt;code&gt;truncate&lt;/code&gt;, &lt;code&gt;slugify&lt;/code&gt;, &lt;code&gt;lower&lt;/code&gt;, &lt;code&gt;upper&lt;/code&gt;, and &lt;code&gt;strip_md&lt;/code&gt; can be chained with pipes. This means you're not locked into someone else's schema — your search index looks exactly the way your frontend expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chunking for granular results
&lt;/h2&gt;

&lt;p&gt;Whole-page results are often too broad for docs search. content-mill can split pages by heading level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;chunking&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;heading&lt;/span&gt;
  &lt;span class="na"&gt;level&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This turns one long page into multiple documents — one per &lt;code&gt;##&lt;/code&gt; section — each with its own &lt;code&gt;chunk_heading&lt;/code&gt;, &lt;code&gt;chunk_body&lt;/code&gt;, and &lt;code&gt;chunk_index&lt;/code&gt;. Your search results can now link directly to the relevant section instead of dumping users at the top of a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero-downtime re-indexing
&lt;/h2&gt;

&lt;p&gt;Every indexing run uses Meilisearch's index swap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Documents go into a temp index (&lt;code&gt;docs_tmp&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Atomic swap with the live index (&lt;code&gt;docs&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Old index gets cleaned up&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If something fails mid-way, your live index is untouched. No maintenance windows needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD in two lines
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# GitHub Actions&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Index docs&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;MEILI_MASTER_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.MEILI_MASTER_KEY }}&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx @centrali-io/content-mill index --config content-mill.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hook this into your release pipeline and your search index stays in sync with every deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use as a library
&lt;/h2&gt;

&lt;p&gt;Don't need the CLI? Import it directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loadConfig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;indexAll&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@centrali-io/content-mill&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;loadConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./content-mill.yml&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;indexAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;dryRun&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or build the config object in code if you prefer programmatic control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not docs-scraper, DocSearch, or a custom crawler?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;docs-scraper&lt;/strong&gt; (the Meilisearch-native option) is a Scrapy-based web crawler. Works well for live sites, heavy for "I already have markdown in a repo."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Algolia DocSearch&lt;/strong&gt; is excellent, but framework-specific and indexes into Algolia — not useful if you've chosen Meilisearch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom scrapers&lt;/strong&gt; work fine for one project. Painful when you have three of them to maintain across different repos.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;content-mill is intentionally narrow: static content in, Meilisearch out, config-driven shape in between. If you're not already on Meilisearch, use something else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @centrali-io/content-mill
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;content-mill.yml&lt;/code&gt; with your Meilisearch connection and source definitions&lt;/li&gt;
&lt;li&gt;Run with &lt;code&gt;--dry-run&lt;/code&gt; first to preview the extracted documents&lt;/li&gt;
&lt;li&gt;Run for real and check your Meilisearch dashboard&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The full config reference and source type examples are in the &lt;a href="https://github.com/blueinit/content-mill" rel="noopener noreferrer"&gt;README on GitHub&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;content-mill is MIT-licensed and open source. If you use Meilisearch and have static content to index, try it — and if your source type isn't covered (AsciiDoc, RST, Notion export, whatever), &lt;a href="https://github.com/blueinit/content-mill/issues" rel="noopener noreferrer"&gt;open an issue&lt;/a&gt; and I'll look at adding an adapter.&lt;/p&gt;

</description>
      <category>meilisearch</category>
      <category>search</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Stop Writing Custom Scrapers: Index Any Static Content into Meilisearch with One Config File</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Wed, 25 Mar 2026 05:16:16 +0000</pubDate>
      <link>https://forem.com/itsmarydan/stop-writing-custom-scrapers-index-any-static-content-into-meilisearch-with-one-config-file-2g65</link>
      <guid>https://forem.com/itsmarydan/stop-writing-custom-scrapers-index-any-static-content-into-meilisearch-with-one-config-file-2g65</guid>
      <description>&lt;p&gt;If you've ever tried to make your docs, blog posts, or changelogs searchable with Meilisearch, you know the drill: write a custom scraper, parse the content, transform it into the right shape, push it to an index, and hope you don't break search during re-indexing.&lt;/p&gt;

&lt;p&gt;I got tired of writing that glue code for every project, so I built &lt;strong&gt;content-mill&lt;/strong&gt; — a CLI and library that indexes static content into Meilisearch from a single YAML config.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Meilisearch is fantastic for search, but getting your content &lt;em&gt;into&lt;/em&gt; it is surprisingly manual. Every docs site, every changelog, every collection of markdown files needs its own extraction pipeline. And if you want zero-downtime re-indexing? That's more code on top.&lt;/p&gt;

&lt;p&gt;Most existing solutions are either tightly coupled to a specific framework (like DocSearch for Algolia) or require you to write a full crawler. If you just have some markdown files and a Meilisearch instance, there's nothing lightweight that bridges the gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  What content-mill Does
&lt;/h2&gt;

&lt;p&gt;You describe your content sources and the document shape you want in a YAML config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;meili&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:7700&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${MEILI_MASTER_KEY}&lt;/span&gt;

&lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docs&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mkdocs&lt;/span&gt;
    &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./mkdocs.yml&lt;/span&gt;
    &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docs&lt;/span&gt;
    &lt;span class="na"&gt;document&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;primaryKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;id&lt;/span&gt;
      &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slug&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;section&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;nav_section&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;docs"&lt;/span&gt;
      &lt;span class="na"&gt;searchableAttributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;filterableAttributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;section&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @centrali-io/content-mill index &lt;span class="nt"&gt;--config&lt;/span&gt; content-mill.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. content-mill reads your sources, extracts content, applies your field templates, and pushes everything to Meilisearch with atomic index swapping (so search never goes down during re-indexing).&lt;/p&gt;

&lt;h2&gt;
  
  
  Four Source Types, One Interface
&lt;/h2&gt;

&lt;p&gt;content-mill ships with adapters for the content formats you're most likely already using:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;mkdocs&lt;/code&gt;&lt;/strong&gt; — Reads your &lt;code&gt;mkdocs.yml&lt;/code&gt;, follows the nav tree, and parses each markdown page. You get &lt;code&gt;nav_section&lt;/code&gt; context so you know which part of the docs each page belongs to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;markdown-dir&lt;/code&gt;&lt;/strong&gt; — Recursively reads &lt;code&gt;.md&lt;/code&gt; files from a directory. Supports YAML frontmatter, so you can pull version numbers, dates, or any metadata into your search index. Great for changelogs and blog posts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;json&lt;/code&gt;&lt;/strong&gt; — Reads a JSON array (or directory of JSON files). Every key in each object becomes a template variable. Perfect for structured data you already have lying around.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;html&lt;/code&gt;&lt;/strong&gt; — Reads &lt;code&gt;.html&lt;/code&gt; files, strips scripts/styles/nav/footer, and gives you clean text. Useful for indexing a built static site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Templating: You Control the Document Shape
&lt;/h2&gt;

&lt;p&gt;The key design decision is that &lt;strong&gt;you&lt;/strong&gt; define what your Meilisearch documents look like. Source adapters extract raw variables (&lt;code&gt;slug&lt;/code&gt;, &lt;code&gt;heading&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, &lt;code&gt;path&lt;/code&gt;, &lt;code&gt;frontmatter.*&lt;/code&gt;, etc.), and you map them to fields using &lt;code&gt;{{ template }}&lt;/code&gt; syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slug&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}-{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_index&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;excerpt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;truncate(200)&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}#{{&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;chunk_heading&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;slugify&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filters like &lt;code&gt;truncate&lt;/code&gt;, &lt;code&gt;slugify&lt;/code&gt;, &lt;code&gt;lower&lt;/code&gt;, &lt;code&gt;upper&lt;/code&gt;, and &lt;code&gt;strip_md&lt;/code&gt; can be chained with pipes. This means you're not locked into someone else's schema — your search index looks exactly the way your frontend expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chunking for Granular Results
&lt;/h2&gt;

&lt;p&gt;Whole-page results are often too broad for docs search. content-mill can split pages by heading level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;chunking&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;heading&lt;/span&gt;
  &lt;span class="na"&gt;level&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This turns one long page into multiple documents — one per &lt;code&gt;##&lt;/code&gt; section — each with its own &lt;code&gt;chunk_heading&lt;/code&gt;, &lt;code&gt;chunk_body&lt;/code&gt;, and &lt;code&gt;chunk_index&lt;/code&gt;. Your search results can now link directly to the relevant section instead of dumping users at the top of a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero-Downtime Re-indexing
&lt;/h2&gt;

&lt;p&gt;Every indexing run uses Meilisearch's index swap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Documents go into a temp index (&lt;code&gt;docs_tmp&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Atomic swap with the live index (&lt;code&gt;docs&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Old index gets cleaned up&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If something fails mid-way, your live index is untouched. No maintenance windows needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD in Two Lines
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# GitHub Actions&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Index docs&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;MEILI_MASTER_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.MEILI_MASTER_KEY }}&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx @centrali-io/content-mill index --config content-mill.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hook this into your release pipeline and your search index stays in sync with every deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use as a Library
&lt;/h2&gt;

&lt;p&gt;Don't need the CLI? Import it directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loadConfig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;indexAll&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@centrali-io/content-mill&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;loadConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./content-mill.yml&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;indexAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;dryRun&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or build the config object in code if you prefer programmatic control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @centrali-io/content-mill
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;content-mill.yml&lt;/code&gt; with your Meilisearch connection and source definitions&lt;/li&gt;
&lt;li&gt;Run with &lt;code&gt;--dry-run&lt;/code&gt; first to preview the extracted documents&lt;/li&gt;
&lt;li&gt;Run for real and check your Meilisearch dashboard&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The full config reference and source type examples are in the &lt;a href="https://github.com/blueinit/content-mill" rel="noopener noreferrer"&gt;README on GitHub&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;content-mill is MIT licensed and open source. If you're using Meilisearch and have static content to index, I'd love to hear how it works for your use case. Issues and PRs welcome on &lt;a href="https://github.com/blueinit/content-mill" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
&lt;em&gt;Tags: #meilisearch #search #typescript #opensource&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

</description>
      <category>meilisearch</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Exponential vs Linear: How to Tell If Your Event-Driven Trigger Is Looping</title>
      <dc:creator>Mary Olowu</dc:creator>
      <pubDate>Sun, 15 Mar 2026 23:46:07 +0000</pubDate>
      <link>https://forem.com/itsmarydan/exponential-vs-linear-how-to-tell-if-your-event-driven-trigger-is-looping-1gc</link>
      <guid>https://forem.com/itsmarydan/exponential-vs-linear-how-to-tell-if-your-event-driven-trigger-is-looping-1gc</guid>
      <description>&lt;h1&gt;
  
  
  Exponential vs Linear: How to Tell If Your Event-Driven Trigger Is Looping
&lt;/h1&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.amazonaws.com%2Fuploads%2Farticles%2Fne8kgwa53mqcx103xz5x.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.amazonaws.com%2Fuploads%2Farticles%2Fne8kgwa53mqcx103xz5x.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Idea
&lt;/h2&gt;

&lt;p&gt;When you're building rate limits for event-driven triggers, you face a fundamental problem: how do you set a threshold that catches loops without blocking legitimate high-volume workloads?&lt;/p&gt;

&lt;p&gt;The answer is that loops and legitimate traffic have fundamentally different growth characteristics:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Legitimate triggers scale linearly with user actions.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 user creates 1 order → 1 trigger execution&lt;/li&gt;
&lt;li&gt;50 users create 50 orders per minute → 50 trigger executions per minute&lt;/li&gt;
&lt;li&gt;The ratio is always 1:1. Trigger executions track user actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Recursive loops scale exponentially from a single user action.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 user creates 1 record → trigger fires → function creates another record → trigger fires again&lt;/li&gt;
&lt;li&gt;After 10 seconds: 100+ executions&lt;/li&gt;
&lt;li&gt;After 60 seconds: 700+ executions&lt;/li&gt;
&lt;li&gt;All from 1 user action. The trigger is its own input.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This isn't a subtle distinction. It's the difference between a line and an exponential curve. And it means your rate limit doesn't need to be clever — it just needs to sit in the massive gap between the two curves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters for Rate Limit Design
&lt;/h2&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.amazonaws.com%2Fuploads%2Farticles%2Ff2ywwvjgjzhq6vlavatu.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.amazonaws.com%2Fuploads%2Farticles%2Ff2ywwvjgjzhq6vlavatu.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A rate limit of 100 executions per 60 seconds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Never blocks legitimate traffic.&lt;/strong&gt; Even a high-volume e-commerce system processing 80 orders per minute sits under the limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always catches loops.&lt;/strong&gt; A recursive loop hits 100 executions in under 8 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The gap between "highest legitimate volume" and "slowest possible loop" is enormous. You don't need machine learning or anomaly detection. You just need basic arithmetic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Math
&lt;/h2&gt;

&lt;p&gt;A recursive trigger loop doubles (at minimum) with each iteration. If one trigger execution creates one record, and that record fires one trigger:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Executions (cumulative)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Iteration 1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iteration 2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iteration 3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iteration 10&lt;/td&gt;
&lt;td&gt;1,024&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Iteration 16&lt;/td&gt;
&lt;td&gt;65,536&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Even with network latency and compute overhead slowing each iteration to 100ms, you hit 100 executions in ~7 seconds. With faster execution (10ms per iteration), you hit 100 in under a second.&lt;/p&gt;

&lt;p&gt;Meanwhile, the highest legitimate trigger volume we've seen across our platform is ~80 executions per minute per trigger — and that's a busy e-commerce workspace during a flash sale.&lt;/p&gt;

&lt;p&gt;The gap is 10x-100x. Your rate limit has a lot of room.&lt;/p&gt;

&lt;h2&gt;
  
  
  What About Burst Traffic?
&lt;/h2&gt;

&lt;p&gt;The natural objection: "What about a bulk import? A user imports 500 records at once, and each fires a trigger."&lt;/p&gt;

&lt;p&gt;This is a valid concern but a different problem:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bulk imports via API&lt;/strong&gt; publish a single aggregate event (&lt;code&gt;records_bulk_created&lt;/code&gt;), not 500 individual events. Event-driven triggers don't match on the aggregate event, so they don't fire at all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Batch operations from compute functions&lt;/strong&gt; do publish individual events. But even 500 trigger executions from a batch operation is a one-time burst, not a sustained loop. If your rate limit window is 60 seconds, the burst registers once. A loop registers continuously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If batch-triggered functions need to fire triggers&lt;/strong&gt;, the rate limit should be configurable per-trigger. Default 100/60s works for 99% of cases. The 1% that needs more can raise it.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Implementing the Test
&lt;/h2&gt;

&lt;p&gt;The simplest implementation is a Redis counter with a TTL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isWithinRateLimit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;triggerId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`trigger_rate:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;triggerId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;incr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&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="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;expire&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&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;That's it. Six lines. The &lt;code&gt;INCR&lt;/code&gt; is atomic (no race conditions across instances), the &lt;code&gt;EXPIRE&lt;/code&gt; handles cleanup, and the threshold separates linear from exponential with a 10x margin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond Rate Limiting
&lt;/h2&gt;

&lt;p&gt;Rate limiting is the safety net, not the whole solution. For a complete defense:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Block obvious loops at configuration time.&lt;/strong&gt; When a user creates a trigger on &lt;code&gt;record_created&lt;/code&gt; for collection X, and the function calls &lt;code&gt;api.createRecord('X', ...)&lt;/code&gt;, reject it with a clear error. This is prevention, not detection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Track causality at runtime.&lt;/strong&gt; Propagate a &lt;code&gt;sourceTriggerId&lt;/code&gt; through event chains so you can identify self-loops without waiting for the rate limit to trip. The user gets a "recursive loop detected" message instead of a vague "rate limit exceeded."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rate limit as the catch-all.&lt;/strong&gt; For cross-trigger chains (A→B→A) and exotic patterns that bypass the first two layers.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We wrote a detailed post about implementing all three layers: &lt;a href="https://medium.com/@olowu.marydan/how-we-stopped-recursive-trigger-loops-from-melting-our-compute-fleet-498a4cb3e5d0" rel="noopener noreferrer"&gt;How We Stopped Recursive Trigger Loops From Melting Our Compute Fleet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Takeaway
&lt;/h2&gt;

&lt;p&gt;If your platform has event-driven triggers, ask yourself: can a trigger's output become its own input? If yes, you need loop protection. And the simplest, most reliable loop protection is a rate limit set in the gap between linear user-driven traffic and exponential recursive behavior.&lt;/p&gt;

&lt;p&gt;That gap is enormous. Use it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Building event-driven infrastructure? We'd love to hear about your trigger architecture challenges. Reach out on [Twitter/X] @centraliio or drop a comment.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>eventdrivenarchitecture</category>
      <category>recursionprevention</category>
      <category>platformengineering</category>
      <category>ratelimiting</category>
    </item>
  </channel>
</rss>
