{
  "updatedAt": "2025-09-20T01:19:24.000Z",
  "createdAt": "2025-09-20T00:00:25.438Z",
  "id": "5sovFDBKRLRlyrJw",
  "name": "Delete Leads from Instantly.ai",
  "active": false,
  "isArchived": true,
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -704,
        -352
      ],
      "id": "49c45e9f-10f6-4b11-9ef5-0c90d0f6b21d",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "ac15169a-d8bb-444f-a666-92fe04aad560",
              "leftValue": "={{ $json.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -48,
        -352
      ],
      "id": "620e44c0-71b1-4dea-a8ca-899c73ab0264",
      "name": "Filter only with emails"
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "german_companies",
        "returnAll": true,
        "filters": {
          "conditions": [
            {
              "keyName": "email",
              "condition": "neq"
            },
            {
              "keyName": "exported_to_instantly",
              "condition": "is",
              "keyValue": "false"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -272,
        -352
      ],
      "id": "256a80c1-e20d-4b23-b6a7-5f95cb1bb943",
      "name": "Get Leads from Supabase",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1712,
        64
      ],
      "id": "0c76ea95-0b72-459a-97ce-70f760f0537d",
      "name": "Wait"
    },
    {
      "parameters": {
        "maxItems": 500
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        224,
        -352
      ],
      "id": "6b275f8f-3372-43dd-b159-a39b375dfe2c",
      "name": "Limit"
    },
    {
      "parameters": {
        "content": "## Load Leads from Supabase",
        "height": 672,
        "width": 832,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -400,
        -624
      ],
      "id": "bbf4cafb-1cb9-4442-bb67-68547dd0db8c",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Chunk Leads and Send to Instantly",
        "height": 512,
        "width": 720
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        704,
        -464
      ],
      "id": "5771d832-dad6-4901-95e6-ad87c24fac3d",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "german_companies",
        "filters": {
          "conditions": [
            {
              "keyName": "website",
              "condition": "is",
              "keyValue": "={{ $json.body.website }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "exported_to_instantly",
              "fieldValue": "=true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1456,
        -112
      ],
      "id": "153b75d4-d262-4113-a8b2-50f12aee424f",
      "name": "Update a row",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "DELETE",
        "url": "https://api.instantly.ai/api/v2/leads/",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "id"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1248,
        -112
      ],
      "id": "cbd0b6c6-cfe1-481d-8812-3db5f66b1edb",
      "name": "Delete Lead",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "return $input.all().map(item => {\n  const data = item.json;\n\n  // Split and clean\n  const emails = (data.email || \"\")\n    .split(\",\")\n    .map(e => e.trim())\n    .filter(e => e.length > 0);\n\n  return {\n    json: {\n      ...data,\n      emails  // now an array of valid emails\n    }\n  };\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        512,
        -336
      ],
      "id": "0bff54f9-4afd-4d4c-bf7f-51a0ffc6fe99",
      "name": "split emails"
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get Leads from Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter only with emails": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Leads from Supabase": {
      "main": [
        [
          {
            "node": "Filter only with emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        []
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "split emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a row": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Lead": {
      "main": [
        [
          {
            "node": "Update a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "split emails": {
      "main": [
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "versionId": "53cf33ab-d77f-4e36-94f6-42109a3e038c",
  "activeVersionId": null,
  "triggerCount": 0,
  "shared": [
    {
      "updatedAt": "2025-09-20T00:00:25.457Z",
      "createdAt": "2025-09-20T00:00:25.457Z",
      "role": "workflow:owner",
      "workflowId": "5sovFDBKRLRlyrJw",
      "projectId": "B7QJE85HA2Vij1it"
    }
  ],
  "activeVersion": null,
  "tags": []
}