{
  "name": "Webhook Relay and Proxy with Logging",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "relay",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "whrp0001-0001-4000-8000-000000000001",
      "name": "Receive Incoming Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "r1", "name": "payload", "value": "={{ $json.body }}", "type": "object" },
            { "id": "r2", "name": "source_ip", "value": "={{ $json.headers['x-forwarded-for'] || 'unknown' }}", "type": "string" },
            { "id": "r3", "name": "received_at", "value": "={{ $now.toISO() }}", "type": "string" },
            { "id": "r4", "name": "event_type", "value": "={{ $json.body.event || $json.body.type || 'unknown' }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "whrp0001-0002-4000-8000-000000000002",
      "name": "Extract and Tag Payload",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.RELAY_TARGET_URL }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Content-Type", "value": "application/json" },
            { "name": "X-Relay-Source", "value": "n8n-relay" },
            { "name": "X-Relay-Timestamp", "value": "={{ $json.received_at }}" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.payload) }}",
        "options": { "timeout": 15000 }
      },
      "id": "whrp0001-0003-4000-8000-000000000003",
      "name": "Forward to Target",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [680, 300]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ ok: true, relayed: true, event_type: $('Extract and Tag Payload').item.json.event_type, timestamp: $('Extract and Tag Payload').item.json.received_at }) }}",
        "options": {}
      },
      "id": "whrp0001-0004-4000-8000-000000000004",
      "name": "Respond to Sender",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Receive Incoming Webhook": {
      "main": [[{ "node": "Extract and Tag Payload", "type": "main", "index": 0 }]]
    },
    "Extract and Tag Payload": {
      "main": [[{ "node": "Forward to Target", "type": "main", "index": 0 }]]
    },
    "Forward to Target": {
      "main": [[{ "node": "Respond to Sender", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
