{
  "name": "Rendex — Cache Render Links in a Data Store (render each item once)",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "hook": 1000201,
        "maxResults": 1
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "Item in (with a stable key)"
        },
        "notes": "Send a JSON body like {\"slug\":\"launch-post\",\"title\":\"We Launched\",\"subtitle\":\"Read the story\"}. 'slug' is the cache key. Swap this for a CMS/Airtable trigger if you prefer — just keep a stable key."
      }
    },
    {
      "id": 2,
      "module": "datastore:GetRecord",
      "version": 1,
      "parameters": {
        "datastore": "__SELECT_YOUR_DATA_STORE__"
      },
      "mapper": {
        "key": "{{1.slug}}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "Data store — Get a record"
        },
        "notes": "One-time: create a Data store (Data stores tab) with a text field 'url'. On import, select it here. Key = {{1.slug}} (or a hash of the fields that determine the image). Returns the stored url, or nothing on a miss."
      }
    },
    {
      "id": 3,
      "module": "builtin:BasicRouter",
      "version": 1,
      "mapper": null,
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "Router — cache hit / miss"
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 4,
              "module": "builtin:BasicFeeder",
              "version": 1,
              "parameters": {},
              "filter": {
                "name": "cache hit — reuse stored URL",
                "conditions": [
                  [
                    {
                      "a": "{{2.url}}",
                      "o": "exist"
                    }
                  ]
                ]
              },
              "mapper": {
                "array": "[{{2.url}}]"
              },
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": -150,
                  "name": "Cache HIT — use {{2.url}}"
                },
                "notes": "Runs only when the Get-a-record returned a url. No render happens — map {{2.url}} into whatever consumes the og:image downstream. (This Iterator is just a placeholder anchor; replace it with your real downstream module.)"
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 5,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {
                "handleErrors": false,
                "useNewZLibDeCompress": true
              },
              "filter": {
                "name": "cache miss — render + store",
                "conditions": [
                  [
                    {
                      "a": "{{2.url}}",
                      "o": "notexist"
                    }
                  ]
                ]
              },
              "mapper": {
                "url": "https://api.rendex.dev/v1/render/link",
                "method": "post",
                "headers": [
                  {
                    "name": "Authorization",
                    "value": "Bearer rdx_YOUR_API_KEY"
                  }
                ],
                "qs": [],
                "bodyType": "raw",
                "contentType": "application/json",
                "data": "{\n  \"html\": \"<div style='width:1200px;height:630px;display:flex;flex-direction:column;justify-content:center;padding:72px;font-family:system-ui;color:#fff;background:linear-gradient(135deg,#0f172a,#ea580c)'><h1 style='font-size:64px;margin:0'>{{title}}</h1><p style='font-size:28px;color:#fed7aa'>{{subtitle}}</p></div>\",\n  \"data\": {\n    \"title\": \"{{1.title}}\",\n    \"subtitle\": \"{{1.subtitle}}\"\n  },\n  \"format\": \"png\",\n  \"width\": 1200,\n  \"height\": 630\n}",
                "serializeUrl": false,
                "shareCookies": false,
                "parseResponse": true,
                "followRedirect": true,
                "useQuerystring": false,
                "followAllRedirects": false,
                "timeout": "",
                "ca": "",
                "rejectUnauthorized": true,
                "gzip": true,
                "useMtls": false
              },
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": 150,
                  "name": "Rendex — Create Render Link (miss only)"
                },
                "restore": {
                  "expect": {
                    "method": { "mode": "chose", "label": "POST" },
                    "bodyType": { "label": "Raw" },
                    "contentType": { "label": "JSON (application/json)" }
                  }
                },
                "notes": "Runs only on a cache miss. POSTs to /v1/render/link for a hosted, edge-cached URL. parseResponse is ON so {{5.url}} is mappable. Replace rdx_YOUR_API_KEY with your key."
              }
            },
            {
              "id": 6,
              "module": "datastore:AddReplaceRecord",
              "version": 1,
              "parameters": {
                "datastore": "__SELECT_YOUR_DATA_STORE__"
              },
              "mapper": {
                "key": "{{1.slug}}",
                "overwrite": true,
                "record": {
                  "url": "{{5.url}}"
                }
              },
              "metadata": {
                "designer": {
                  "x": 1200,
                  "y": 150,
                  "name": "Data store — store the URL"
                },
                "notes": "Writes the freshly rendered URL to the store under the same key, so the next run for this item is a cache hit. Select the same Data store you used above."
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "zone": "us1.make.com"
  }
}
