<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thomas</title>
    <description>The latest articles on DEV Community by Thomas (@thomas_cinfolog).</description>
    <link>https://dev.to/thomas_cinfolog</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4243825%2F2b9b8515-78ea-4856-8e1d-fb139bd3f058.png</url>
      <title>DEV Community: Thomas</title>
      <link>https://dev.to/thomas_cinfolog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thomas_cinfolog"/>
    <language>en</language>
    <item>
      <title>Shopify deletes API-created webhook subscriptions after 8 failures. An n8n safety net, no Code node</title>
      <dc:creator>Thomas</dc:creator>
      <pubDate>Mon, 16 Nov 2026 14:50:04 +0000</pubDate>
      <link>https://dev.to/thomas_cinfolog/shopify-deletes-api-created-webhook-subscriptions-after-8-failures-an-n8n-safety-net-no-code-node-4ab8</link>
      <guid>https://dev.to/thomas_cinfolog/shopify-deletes-api-created-webhook-subscriptions-after-8-failures-an-n8n-safety-net-no-code-node-4ab8</guid>
      <description>&lt;p&gt;Picture a shop that keeps taking orders all weekend while your n8n container sits in a restart loop. Every delivery fails. Shopify &lt;a href="https://shopify.dev/docs/apps/build/webhooks/subscribe/https" rel="noopener noreferrer"&gt;retries 8 times over 4 hours&lt;/a&gt;, and "after 8 consecutive failures, the subscription is automatically deleted if it was configured using the Admin API." On Monday n8n is healthy again, and silent. Nothing ran, so nothing failed, so no error workflow fired.&lt;/p&gt;

&lt;p&gt;That rule applies to shop-specific subscriptions, the ones created with &lt;code&gt;webhookSubscriptionCreate&lt;/code&gt;: the usual route when there is no app project (no &lt;code&gt;shopify.app.toml&lt;/code&gt;, no CLI). App-specific ones are treated differently (next section).&lt;/p&gt;


&lt;div class="crayons-card c-embed"&gt;

  &lt;br&gt;
&lt;strong&gt;What this post builds, with native nodes only (no Code node)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;receiver&lt;/strong&gt;: HMAC check on the raw body, a fast 200, then a re-read of the order from the GraphQL Admin API instead of trusting the payload.&lt;/li&gt;
&lt;li&gt;An &lt;strong&gt;hourly workflow&lt;/strong&gt; with two branches: a &lt;strong&gt;reconciliation&lt;/strong&gt; resuming from a stored checkpoint, and a &lt;strong&gt;watchdog&lt;/strong&gt; that re-creates the subscription if it vanished.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both were run on n8n 2.46.6 against a mock GraphQL endpoint and PostgreSQL 16, not a live shop. API version: &lt;code&gt;2026-10&lt;/code&gt;, the latest stable at the time of writing.&lt;br&gt;

&lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Do you need any of this? TOML versus API
&lt;/h2&gt;

&lt;p&gt;Shopify's own advice: "Choose app-specific subscriptions unless your topics, delivery URIs, or filters need to vary between shops." Per its &lt;a href="https://shopify.dev/docs/apps/build/webhooks/subscribe" rel="noopener noreferrer"&gt;subscription docs&lt;/a&gt;, failing app-specific subscriptions "will not be deleted by Shopify"; failing shop-specific ones "will be deleted".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[webhooks]&lt;/span&gt;
&lt;span class="na"&gt;api_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"2026-10"&lt;/span&gt;

&lt;span class="k"&gt;[[webhooks.subscriptions]]&lt;/span&gt;
&lt;span class="na"&gt;topics&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"orders/updated"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="na"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://YOUR_N8N_HOST/webhook/shopify/orders-updated"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That block goes in &lt;code&gt;shopify.app.toml&lt;/code&gt; and ships with &lt;code&gt;shopify app deploy&lt;/code&gt; (syntax from Shopify's docs; not deployed in the test run).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My default:&lt;/strong&gt; use it whenever there is an app project and one URL serves every shop. The watchdog below is then pointless, since &lt;code&gt;webhookSubscriptions&lt;/code&gt; "returns only shop-scoped subscriptions, not app-scoped subscriptions configured in TOML files".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay with the API&lt;/strong&gt; when the URL differs per shop or there is no app project. The reconciliation job is worth having either way: deliveries can still be missed.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Shopify promises
&lt;/h2&gt;

&lt;p&gt;From the &lt;a href="https://shopify.dev/docs/apps/build/webhooks" rel="noopener noreferrer"&gt;webhooks overview&lt;/a&gt;, the &lt;a href="https://shopify.dev/docs/apps/build/webhooks/subscribe/https" rel="noopener noreferrer"&gt;HTTPS delivery page&lt;/a&gt; and &lt;a href="https://shopify.dev/docs/apps/build/webhooks/ignore-duplicates" rel="noopener noreferrer"&gt;ignoring duplicates&lt;/a&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;What to know&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Timeouts&lt;/td&gt;
&lt;td&gt;One second to connect, five for the whole request; anything outside the 200 range is an error.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retries&lt;/td&gt;
&lt;td&gt;8 retries over 4 hours, then deletion (API-created subscriptions). Warning emails go to the app's emergency developer address.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ordering&lt;/td&gt;
&lt;td&gt;No guarantee. Sort with &lt;code&gt;X-Shopify-Triggered-At&lt;/code&gt; or the payload's &lt;code&gt;updated_at&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duplicates&lt;/td&gt;
&lt;td&gt;They happen. Deduplicate on &lt;code&gt;X-Shopify-Webhook-Id&lt;/code&gt;; &lt;code&gt;X-Shopify-Event-Id&lt;/code&gt; only correlates deliveries from one merchant action.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reconciliation&lt;/td&gt;
&lt;td&gt;Recommended: fetch objects updated "since the last time the job ran".&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep the webhooks and add one cheap poll an hour as a safety net.&lt;/p&gt;


&lt;div class="crayons-card c-embed"&gt;

  &lt;br&gt;
&lt;strong&gt;The webhook is a doorbell, not the parcel.&lt;/strong&gt; Take the order ID from it and ask Shopify for the current state: out-of-order deliveries mostly stop mattering, and both paths feed the same upsert. The price is one API call per event; on a Standard plan &lt;a href="https://shopify.dev/docs/apps/build/apis/graphql-admin/rate-limits" rel="noopener noreferrer"&gt;the GraphQL budget is 100 points per second&lt;/a&gt;.&lt;br&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Subscribe, and authenticate in 2026
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create the subscription
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="n"&gt;mutation&lt;/span&gt; &lt;span class="nc"&gt;CreateOrdersUpdated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;WebhookSubscriptionInput&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;webhookSubscriptionCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ORDERS_UPDATED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;webhookSubscription&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; $&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;webhookSubscription&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;userErrors&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="n"&gt;message&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"uri"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://YOUR_N8N_HOST/webhook/shopify/orders-updated"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"format"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"JSON"&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;POST it to &lt;code&gt;https://YOUR_SHOP.myshopify.com/admin/api/2026-10/graphql.json&lt;/code&gt; (&lt;code&gt;callbackUrl&lt;/code&gt; is deprecated, use &lt;code&gt;uri&lt;/code&gt;). Use the production URL: n8n registers it when the workflow is published.&lt;/p&gt;
&lt;h3&gt;
  
  
  Get a token
&lt;/h3&gt;

&lt;p&gt;Tokens changed in 2026. &lt;a href="https://shopify.dev/changelog/posts/legacy-custom-apps-can-t-be-created-after-january-1-2026" rel="noopener noreferrer"&gt;New custom apps can't be created in the admin&lt;/a&gt; any more (existing ones keep working); they come from the Dev Dashboard. A token from the &lt;a href="https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/client-credentials-grant" rel="noopener noreferrer"&gt;client credentials grant&lt;/a&gt; lives 86,399 seconds, about a day, and only works for apps your organization owns.&lt;/p&gt;

&lt;p&gt;A static header credential would break after a day, so the workflows fetch a token first: an HTTP Request node posts to &lt;code&gt;/admin/oauth/access_token&lt;/code&gt; with a &lt;em&gt;Custom Auth&lt;/em&gt; credential, then the GraphQL node's Headers option sends &lt;code&gt;X-Shopify-Access-Token&lt;/code&gt;. The credential's JSON makes the request a form, as Shopify requires, and keeps the secret out of the workflow:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/x-www-form-urlencoded"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"grant_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"client_credentials"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"YOUR_CLIENT_ID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"client_secret"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"YOUR_CLIENT_SECRET"&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;Without the &lt;code&gt;Content-Type&lt;/code&gt; header, n8n 2.46.6 sent the same body as JSON; with it, the mock received the three fields form-encoded. With a non-expiring token (older admin-created app), drop the token node and use a Header Auth credential.&lt;/p&gt;

&lt;p&gt;The HMAC key is the app's client secret, kept in a Crypto credential.&lt;/p&gt;
&lt;h2&gt;
  
  
  Workflow 1: the receiver
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Webhook&lt;/strong&gt;: POST, path &lt;code&gt;shopify/orders-updated&lt;/code&gt;, Respond: &lt;em&gt;Using 'Respond to Webhook' Node&lt;/em&gt;, option &lt;strong&gt;Raw Body&lt;/strong&gt; on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crypto&lt;/strong&gt;: Hmac, &lt;strong&gt;Binary File&lt;/strong&gt; on, property &lt;code&gt;data&lt;/code&gt;, SHA256, output &lt;code&gt;computed_hmac&lt;/code&gt;, BASE64.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IF&lt;/strong&gt;: &lt;code&gt;computed_hmac&lt;/code&gt; equals the &lt;code&gt;x-shopify-hmac-sha256&lt;/code&gt; header (node headers are lower-cased).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respond to Webhook&lt;/strong&gt;: &lt;em&gt;No Data&lt;/em&gt;, 200 on true; 401 on false, followed by a &lt;strong&gt;Stop and Error&lt;/strong&gt; node.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Request&lt;/strong&gt; (token), then &lt;strong&gt;GraphQL&lt;/strong&gt; (order by ID), then an &lt;strong&gt;IF&lt;/strong&gt; on &lt;code&gt;order&lt;/code&gt; being null, &lt;strong&gt;Edit Fields&lt;/strong&gt;, and the &lt;strong&gt;Postgres&lt;/strong&gt; upsert.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The expressions used in the IF and GraphQL nodes:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{ $json.computed_hmac }}  equals  {{ $json.headers['x-shopify-hmac-sha256'] }}
variables: {{ { "id": $('Shopify webhook').item.json.body.admin_graphql_api_id } }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The order query:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="nc"&gt;OrderById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; $&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;updatedAt&lt;/span&gt; &lt;span class="n"&gt;displayFinancialStatus&lt;/span&gt; &lt;span class="n"&gt;displayFulfillmentStatus&lt;/span&gt;
    &lt;span class="n"&gt;currentTotalPriceSet&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;shopMoney&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="n"&gt;currencyCode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Why it is built this way
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Raw Body.&lt;/strong&gt; The HMAC covers the exact bytes Shopify sent; re-serialised JSON won't match. With Raw Body on, the bytes arrive in a binary property that the Crypto node hashes directly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;200 before the work.&lt;/strong&gt; The Respond node sits before the token and GraphQL calls, so Shopify's clock stops there. If the fetch fails, the reconciliation picks the order up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stop and Error after the 401.&lt;/strong&gt; If the client secret is wrong or mistyped, every real delivery fails the HMAC check. Shopify counts those 401s as failures, but without this node n8n shows them as successful executions. With it they fail and your Error Workflow fires (so does a forged request: rate-limit that alert). The IF is not a constant-time comparison; I consider that acceptable for a base64 HMAC over the internet, but do the check in a reverse proxy if you disagree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;order: null&lt;/code&gt;.&lt;/strong&gt; A deleted order, or one outside the default 60-day reach, comes back as &lt;code&gt;null&lt;/code&gt;. The IF skips it instead of failing on &lt;code&gt;data.order.id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GraphQL node, not HTTP Request.&lt;/strong&gt; Shopify can answer &lt;a href="https://shopify.dev/docs/apps/launch/protected-customer-data" rel="noopener noreferrer"&gt;HTTP 200 with the error in &lt;code&gt;errors&lt;/code&gt;&lt;/a&gt;, for unapproved protected data for instance. A mock doing that passed through the HTTP Request node as a normal item, while the GraphQL node failed. Don't set it to &lt;em&gt;Continue (using error output)&lt;/em&gt;: the error body then leaves on both outputs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Workflow 2: reconciliation and watchdog
&lt;/h2&gt;

&lt;p&gt;Two Schedule Triggers, so a failure in one branch can't stop the other.&lt;/p&gt;
&lt;h3&gt;
  
  
  Reconciliation with a checkpoint
&lt;/h3&gt;

&lt;p&gt;Shopify's docs say to fetch objects updated "since the last time the job ran", so the run state is stored in a &lt;code&gt;sync_state&lt;/code&gt; table, read and written by Postgres nodes. The first node computes the lower bound and this run's start, once:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="nf"&gt;to_char&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;COALESCE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;last_started_at&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;sync_state&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'orders_reconciliation'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kt"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'24 hours'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kt"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'1 hour'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;AT&lt;/span&gt; &lt;span class="kt"&gt;TIME&lt;/span&gt; &lt;span class="no"&gt;ZONE&lt;/span&gt; &lt;span class="s1"&gt;'UTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="s1"&gt;'YYYY-MM-DD"T"HH24:MI:SS"Z"'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;since&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;to_char&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;AT&lt;/span&gt; &lt;span class="kt"&gt;TIME&lt;/span&gt; &lt;span class="no"&gt;ZONE&lt;/span&gt; &lt;span class="s1"&gt;'UTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'YYYY-MM-DD"T"HH24:MI:SS"Z"'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;run_started_at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Every page of a run uses the same filter, because the GraphQL node reads &lt;code&gt;since&lt;/code&gt; from that node (a &lt;code&gt;$now&lt;/code&gt;-based expression had drifted by a second between pages):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{ { "q": "updated_at:&amp;gt;='" + $('Read last sync point').first().json.since + "'", "cursor": $json.data?.orders?.pageInfo?.endCursor ?? null } }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="nc"&gt;RecentOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; $&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; $&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; $&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sortKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;UPDATED_AT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;updatedAt&lt;/span&gt; &lt;span class="n"&gt;displayFinancialStatus&lt;/span&gt; &lt;span class="n"&gt;displayFulfillmentStatus&lt;/span&gt;
            &lt;span class="n"&gt;currentTotalPriceSet&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;shopMoney&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="n"&gt;currencyCode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;pageInfo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;hasNextPage&lt;/span&gt; &lt;span class="n"&gt;endCursor&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;One &lt;strong&gt;Postgres&lt;/strong&gt; node upserts the whole page in a single statement, then an &lt;strong&gt;Edit Fields&lt;/strong&gt; node puts the GraphQL response back (Postgres returns its own result, not the page), and an &lt;strong&gt;IF&lt;/strong&gt; on &lt;code&gt;hasNextPage&lt;/code&gt; loops back into the GraphQL node. On the last page the IF's false output runs &lt;strong&gt;Save sync point&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The page upsert:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;shopify_orders&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;financial_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fulfillment_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"displayFinancialStatus"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"displayFulfillmentStatus"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"currentTotalPriceSet"&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'shopMoney'&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"currentTotalPriceSet"&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'shopMoney'&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'currencyCode'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;"updatedAt"&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nf"&gt;jsonb_to_recordset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;jsonb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"updatedAt"&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"displayFinancialStatus"&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"displayFulfillmentStatus"&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"currentTotalPriceSet"&lt;/span&gt; &lt;span class="kt"&gt;jsonb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;CONFLICT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;SET&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;financial_status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;financial_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;fulfillment_status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fulfillment_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;shopify_orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The parameter and the Edit Fields value:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query Parameters:  {{ [ JSON.stringify($json.data.orders.nodes) ] }}
Edit Fields (JSON): {{ $('Orders updated since the last sync').first().json }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The checkpoint:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;sync_state&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_started_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'orders_reconciliation'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;timestamptz&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;CONFLICT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;last_started_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_started_at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Why one chain.&lt;/strong&gt; The obvious design splits each page into a per-order upsert branch and a "Another page?" branch feeding Save, but with n8n's &lt;code&gt;v1&lt;/code&gt; execution order the branches leaving a node run top to bottom &lt;em&gt;by canvas position&lt;/em&gt;, so moving nodes around could run Save despite a failed upsert. Here &lt;em&gt;Save sync point&lt;/em&gt; has a single input, the IF's false output, and the IF only receives an item after &lt;em&gt;Upsert page&lt;/em&gt; succeeded, wherever the nodes sit. One statement per page is also atomic, and an empty page still emits an item (&lt;code&gt;jsonb_to_recordset&lt;/code&gt; on &lt;code&gt;[]&lt;/code&gt; inserts nothing), so the checkpoint moves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the test run:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Failure.&lt;/strong&gt; Postgres was made to reject one order with a &lt;code&gt;CHECK&lt;/code&gt; constraint, once on the second page and once on the first. The execution failed at &lt;em&gt;Upsert page&lt;/em&gt; and &lt;code&gt;sync_state&lt;/code&gt; kept its old value; with the constraint removed, the next run started again from it. The test was repeated with the chain laid out in reverse order on the canvas: same result in all four cases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gaps.&lt;/strong&gt; After a simulated six-hour gap, the next run asked for everything since seven hours ago, which is what an outage long enough to delete a subscription needs. An empty page still saved the checkpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overlap.&lt;/strong&gt; The one-hour look-back absorbs clock skew and search-index lag; the upsert makes the repeats harmless, and a row already newer in the database is not overwritten.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't use &lt;code&gt;max(updated_at)&lt;/code&gt; of your orders table as the checkpoint: the webhook path writes there too, and one live delivery after an outage would move it past the hole.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Watchdog
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="nc"&gt;SubscriptionCheck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;webhookSubscriptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topics&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;ORDERS_UPDATED&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; $&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt; &lt;span class="n"&gt;uri&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;If &lt;code&gt;nodes.length&lt;/code&gt; is 0, the &lt;code&gt;CreateOrdersUpdated&lt;/code&gt; mutation runs and the alert includes its &lt;code&gt;userErrors&lt;/code&gt;, so you can tell "re-created" from "tried and failed". The first test run created the subscription and alerted; the second did nothing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The watchdog runs on the instance it watches, so it can't notice that instance dying. Poll &lt;code&gt;/healthz&lt;/code&gt; from an external monitor, and make sure someone reads the emergency developer mailbox.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  The tables
&lt;/h2&gt;

&lt;p&gt;&lt;/p&gt;
  SQL for shopify_orders and sync_state
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;shopify_orders&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;gid&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;financial_status&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;fulfillment_status&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="kt"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;currency&lt;/span&gt; &lt;span class="kt"&gt;char&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="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;sync_state&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_started_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&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;&lt;/p&gt;

&lt;p&gt;The receiver runs the same &lt;code&gt;INSERT ... ON CONFLICT (gid) DO UPDATE ... WHERE shopify_orders.updated_at &amp;lt;= EXCLUDED.updated_at&lt;/code&gt; with a &lt;code&gt;VALUES ($1, ... $7)&lt;/code&gt; list, fed by an array expression (&lt;code&gt;{{ [ $json.id, $json.name, ... ] }}&lt;/code&gt;) rather than a comma-separated string, so a comma in a value can't shift columns. The &lt;code&gt;WHERE&lt;/code&gt; guard refuses older data when two executions for the same order finish out of order.&lt;/p&gt;
&lt;h2&gt;
  
  
  Self-hosting notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shopify must reach the webhook, nobody else the editor.&lt;/strong&gt; Cloudflare Access in front of the editor with a Bypass policy on &lt;code&gt;/webhook&lt;/code&gt; does both. My write-up of that setup, with the rest of a small VPS stack: &lt;a href="https://cinfolog.com/articles/heberger-n8n-vps-france" rel="noopener noreferrer"&gt;self-hosting n8n on a French VPS&lt;/a&gt; (in French).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Behind a reverse proxy, set the public URL&lt;/strong&gt;: &lt;code&gt;N8N_WEBHOOK_URL&lt;/code&gt;, plus &lt;code&gt;N8N_PROXY_HOPS=1&lt;/code&gt;, per &lt;a href="https://docs.n8n.io/hosting/configuration/configuration-examples/webhook-url/" rel="noopener noreferrer"&gt;n8n's docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The token ends up in the execution history.&lt;/strong&gt; After the test runs, the 24-hour token was found in every stored execution that fetched one (the client secret in none, since it stays in the credential). Turn off &lt;em&gt;Save successful production executions&lt;/em&gt; for the receiver, or set &lt;code&gt;EXECUTIONS_DATA_SAVE_ON_SUCCESS=none&lt;/code&gt; and a short &lt;code&gt;EXECUTIONS_DATA_MAX_AGE&lt;/code&gt; (&lt;a href="https://docs.n8n.io/hosting/configuration/environment-variables/executions/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;); failed executions keep it too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The client secret lives in two credentials&lt;/strong&gt;, Crypto (HMAC key) and Custom Auth (token request). Rotate both: miss the Custom Auth one and token calls fail; miss the Crypto one and every real webhook gets a 401, which Stop and Error makes visible.&lt;/li&gt;
&lt;li&gt;A restart of a few seconds is covered by Shopify's retries. A stuck container is covered by the checkpoint (the data) and the watchdog (the subscription).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What this doesn't solve
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write-back loops.&lt;/strong&gt; If the upsert step edits the order in Shopify (tags, metafields), Shopify emits another &lt;code&gt;orders/updated&lt;/code&gt;. Mark your own writes and skip them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token caching.&lt;/strong&gt; The receiver requests a token per event. No documented limit on the token endpoint turned up, so it's unclear where that stops being fine; at volume, cache the token (it lives 24 hours) in a table or an n8n Data Table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A live shop.&lt;/strong&gt; Everything ran against mocks and a temporary Postgres. The &lt;code&gt;updated_at:&amp;gt;='...'&lt;/code&gt; filter follows Shopify's documented syntax but wasn't run on real orders; try it on a development store.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Test the receiver without a shop
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;BODY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{"admin_graphql_api_id":"gid://shopify/Order/42","updated_at":"2026-11-05T10:00:00-05:00"}'&lt;/span&gt;
&lt;span class="nv"&gt;SIG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s'&lt;/span&gt; &lt;span class="s2"&gt;"$BODY"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; openssl dgst -sha256 -hmac &lt;span class="s1"&gt;'YOUR_CLIENT_SECRET'&lt;/span&gt; -binary &lt;span class="o"&gt;|&lt;/span&gt; base64&lt;span class="o"&gt;)&lt;/span&gt;
curl -s -o /dev/null -w &lt;span class="s2"&gt;"%{http_code}\n"&lt;/span&gt; -X POST -H &lt;span class="s1"&gt;'content-type: application/json'&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"X-Shopify-Hmac-Sha256: $SIG"&lt;/span&gt; --data-binary &lt;span class="s2"&gt;"$BODY"&lt;/span&gt; \
  https://YOUR_N8N_HOST/webhook/shopify/orders-updated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Expected: 200 for a valid signature, 401 for another secret, a changed body or a missing header.&lt;/p&gt;
&lt;h2&gt;
  
  
  Your turn
&lt;/h2&gt;


&lt;div class="crayons-card c-embed"&gt;

  &lt;br&gt;
How would you notice today that an API-created subscription had disappeared: alerting on silence, a scheduled re-check like this one, or just moving to TOML? Tell me what the design above misses.&lt;br&gt;

&lt;/div&gt;






&lt;p&gt;I'm Thomas, a freelance integrator (Shopify, HubSpot, n8n) based near Bordeaux. I work under the &lt;a href="https://cinfolog.com" rel="noopener noreferrer"&gt;Cinfolog&lt;/a&gt; brand &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Drafted with AI assistance. I reviewed it and stand by every claim; corrections welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>n8n</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
