{
  "name": "Clean a mailing list with Dedupe.dev (dedupe + validate)",
  "nodes": [
    {
      "parameters": {},
      "id": "c1e2a3b4-0000-4000-9000-000000000001",
      "name": "Run",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [220, 300]
    },
    {
      "parameters": {
        "jsCode": "// Replace this node with your real source (spreadsheet read, DB query,\n// webhook body). It must output one item with a `data` string of\n// newline-separated email addresses.\nconst emails = [\n  'ann@example.com',\n  'Ann@Example.com',\n  'bob@example.com',\n  'burner@mailinator.com',\n  'not-an-email',\n  'ann@example.com',\n];\nreturn [{ json: { data: emails.join('\\n') } }];"
      },
      "id": "c1e2a3b4-0000-4000-9000-000000000002",
      "name": "Your list (sample data)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [420, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://dedupe.dev/api/dedupe",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ mode: 'lines', data: $json.data, options: { ignoreCase: true, trim: true, dropEmpty: true } }) }}",
        "options": {}
      },
      "id": "c1e2a3b4-0000-4000-9000-000000000003",
      "name": "1. Dedupe",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [620, 300],
      "notes": "Removes exact duplicates (case-insensitive, trimmed). Response: result (array of surviving lines), kept, removed."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://dedupe.dev/api/validate",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ emails: $json.result }) }}",
        "options": {}
      },
      "id": "c1e2a3b4-0000-4000-9000-000000000004",
      "name": "2. Validate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [820, 300],
      "notes": "Hygiene-grade checks per address: syntax, MX, disposable domain, role account. Bills 2 units per address. Response: results[] with verdicts plus a summary."
    },
    {
      "parameters": {
        "jsCode": "// Keep only the addresses that passed every check. Role accounts (info@,\n// support@) are valid but flagged; drop them too by adding `&& !r.role`.\nconst clean = $json.results.filter(r => r.valid).map(r => r.email);\nreturn [{ json: { clean, summary: $json.summary } }];"
      },
      "id": "c1e2a3b4-0000-4000-9000-000000000005",
      "name": "3. Keep the valid ones",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1020, 300]
    }
  ],
  "connections": {
    "Run": {
      "main": [[{ "node": "Your list (sample data)", "type": "main", "index": 0 }]]
    },
    "Your list (sample data)": {
      "main": [[{ "node": "1. Dedupe", "type": "main", "index": 0 }]]
    },
    "1. Dedupe": {
      "main": [[{ "node": "2. Validate", "type": "main", "index": 0 }]]
    },
    "2. Validate": {
      "main": [[{ "node": "3. Keep the valid ones", "type": "main", "index": 0 }]]
    }
  },
  "settings": {},
  "pinData": {}
}
