{
  "name": "GTM Tested - validate lead intake (configure auth before use)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "gtm-tested-lead-intake",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "intake",
      "name": "Lead intake",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "gtm-tested-lead-intake"
    },
    {
      "parameters": {
        "jsCode": "return items.map(({json}) => {\n  const input = json.body ?? json;\n  const email = String(input.email ?? '').trim().toLowerCase();\n  const domain = String(input.company_domain ?? '').trim().toLowerCase();\n  const valid = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email) && /^[a-z0-9.-]+\\.[a-z]{2,}$/.test(domain);\n  return {json: {accepted: valid, email, company_domain: domain, idempotency_key: String(input.event_id ?? `${email}:${domain}`), error: valid ? null : 'A syntactically valid email and company_domain are required. Syntax validation does not establish deliverability.'}};\n});"
      },
      "id": "validate",
      "name": "Validate record",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {
          "responseCode": "={{ $json.accepted ? 200 : 400 }}"
        }
      },
      "id": "respond",
      "name": "Return validation",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        520,
        0
      ]
    }
  ],
  "connections": {
    "Lead intake": {
      "main": [
        [
          {
            "node": "Validate record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate record": {
      "main": [
        [
          {
            "node": "Return validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "pinData": {}
}