{
  "name": "Synthetic Lead Intake - Hardened After QA",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "synthetic-lead-intake",
        "options": {}
      },
      "id": "c57a7f9c-163d-4b45-93ef-1d9109864915",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "synthetic-demo-webhook"
    },
    {
      "parameters": {
        "jsCode": "const source = $json.body ?? $json;\nconst email = String(source.email ?? '').trim().toLowerCase();\nconst company = String(source.company ?? '').trim();\nconst domain = String(source.domain ?? '').trim().toLowerCase();\nconst sourceEventId = String(source.event_id ?? source.eventId ?? '').trim();\n\nif (!email || !email.includes('@')) throw new Error('required_email_missing_or_invalid');\nif (!company) throw new Error('required_company_missing');\nif (!domain) throw new Error('required_domain_missing');\n\nconst leadKey = sourceEventId || `${email}|${domain}`;\nreturn [{ json: { email, company, domain, source_event_id: sourceEventId || null, lead_key: leadKey } }];"
      },
      "id": "0c69251e-3faf-4a74-bf6f-95bf77404a01",
      "name": "Validate + normalize",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [240, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.invalid/enrich",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { domain: $json.domain, company: $json.company } }}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "516ae994-a254-46fb-a5b8-19ca9c1691f6",
      "name": "Enrich company",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [500, 0],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.invalid/crm/contacts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ $('Validate + normalize').item.json.lead_key }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { email: $('Validate + normalize').item.json.email, company: $('Validate + normalize').item.json.company, domain: $('Validate + normalize').item.json.domain, enrichment: $json } }}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "4551590d-1647-46f9-86c4-a1579fc25dc1",
      "name": "Create CRM contact",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [760, 0],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "jsCode": "const response = $json;\nconst contactId = response.id ?? response.contactId ?? response.contact_id;\nif (!contactId) {\n  throw new Error('crm_outcome_not_proven_missing_contact_id');\n}\nreturn [{ json: { ...response, verified_contact_id: String(contactId) } }];"
      },
      "id": "20de6247-0c07-4f18-9534-58bf84be6241",
      "name": "Assert CRM outcome",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1020, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.invalid/slack",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { text: 'New lead: ' + $('Validate + normalize').item.json.email + ' | CRM: ' + $json.verified_contact_id } }}",
        "options": {
          "timeout": 5000
        }
      },
      "id": "f721337e-c454-42f8-a2f4-e535acde7eb8",
      "name": "Notify Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1280, 0],
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 1000
    }
  ],
  "connections": {
    "Webhook": {
      "main": [[{"node":"Validate + normalize","type":"main","index":0}]]
    },
    "Validate + normalize": {
      "main": [[{"node":"Enrich company","type":"main","index":0}]]
    },
    "Enrich company": {
      "main": [[{"node":"Create CRM contact","type":"main","index":0}]]
    },
    "Create CRM contact": {
      "main": [[{"node":"Assert CRM outcome","type":"main","index":0}]]
    },
    "Assert CRM outcome": {
      "main": [[{"node":"Notify Slack","type":"main","index":0}]]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "versionId": "d2d3574a-a69b-4e10-a141-ced9082ecf9b",
  "meta": {
    "templateCredsSetupCompleted": false,
    "syntheticExample": true,
    "warning": "Illustrative only. example.invalid endpoints are intentionally non-routable. The Idempotency-Key assumes the synthetic CRM endpoint honors that contract."
  },
  "tags": []
}