{
  "name": "Redax → API custom (générique)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "redax-generic",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-redax",
      "name": "Webhook Redax",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "redax-generic"
    },
    {
      "parameters": {
        "language": "javaScript",
        "jsCode": "// Vérifie la signature HMAC SHA256 envoyée par Redax\nconst crypto = require('crypto');\n\n// REMPLACE par ton secret Redax (depuis /settings/webhooks)\nconst REDAX_WEBHOOK_SECRET = 'whsec_REPLACE_WITH_YOUR_SECRET';\n\nconst signature = $input.first().json.headers['x-redax-signature'];\nconst payload = JSON.stringify($input.first().json.body);\n\nif (!signature) {\n  throw new Error('Missing X-Redax-Signature header');\n}\n\nconst expectedSig = 'sha256=' + crypto\n  .createHmac('sha256', REDAX_WEBHOOK_SECRET)\n  .update(payload)\n  .digest('hex');\n\nif (signature !== expectedSig) {\n  throw new Error('Invalid HMAC signature - request rejected');\n}\n\nreturn $input.all();"
      },
      "id": "verify-hmac",
      "name": "Verify HMAC",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            {
              "id": "1",
              "leftValue": "={{ $json.body.event }}",
              "rightValue": "article.generated",
              "operator": { "type": "string", "operation": "equals" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "filter-event",
      "name": "Only article.generated",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://CUSTOMIZE_ME.example.com/articles",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"{{ $json.body.data.title }}\",\n  \"content\": \"{{ $json.body.data.content_html }}\",\n  \"excerpt\": \"{{ $json.body.data.meta_description }}\",\n  \"slug\": \"{{ $json.body.data.title.toLowerCase().replace(/\\\\s+/g, '-') }}\"\n}",
        "options": {}
      },
      "id": "custom-http",
      "name": "HTTP Request — Customize Me",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [900, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={ \"received\": true, \"forwarded\": true }",
        "options": {}
      },
      "id": "respond-ok",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1120, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={ \"received\": true, \"skipped\": \"event_not_handled\" }",
        "options": {}
      },
      "id": "respond-skip",
      "name": "Respond Skip",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [900, 400]
    }
  ],
  "connections": {
    "Webhook Redax": { "main": [[{ "node": "Verify HMAC", "type": "main", "index": 0 }]] },
    "Verify HMAC": { "main": [[{ "node": "Only article.generated", "type": "main", "index": 0 }]] },
    "Only article.generated": {
      "main": [
        [{ "node": "HTTP Request — Customize Me", "type": "main", "index": 0 }],
        [{ "node": "Respond Skip", "type": "main", "index": 0 }]
      ]
    },
    "HTTP Request — Customize Me": { "main": [[{ "node": "Respond OK", "type": "main", "index": 0 }]] }
  }
}
