{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "4ea0189c-83eb-4c95-92f8-db9b3dd9b521",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        20,
        150
      ],
      "parameters": {
        "path": "abf99fbe-fa03-4f55-b978-db7cba42a565",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "0f8a3ab7-8fae-4d94-8721-05239e402a34",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueErrorOutput",
      "position": [
        680,
        150
      ],
      "parameters": {
        "options": {
          "reset": "={{ false }}"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "7027161a-72ee-47b7-b393-a71a0e9d37f9",
      "name": "Replace Me",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1560,
        150
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a376ab8e-d925-4c06-a019-1da903a4a5c4",
      "name": "Delete Contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1340,
        0
      ],
      "parameters": {
        "contactId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "operation": "delete",
        "authentication": "appToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "b7fb3731-255b-4a06-8bb0-51a896721bd5",
      "name": "Search Contact",
      "type": "n8n-nodes-base.hubspot",
      "onError": "continueRegularOutput",
      "position": [
        900,
        75
      ],
      "parameters": {
        "limit": 1,
        "operation": "search",
        "authentication": "appToken",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ $json.email }}",
                    "propertyName": "email|string"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "7f7059cc-cd26-43d5-9006-cd56cf020bce",
      "name": "If contact exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        75
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "dbb5bafc-0939-492f-811f-4bbbfcbbf09d",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b1e62cd8-5745-4912-9303-2982fa0a26f5",
      "name": "Parse Data",
      "type": "n8n-nodes-base.set",
      "position": [
        460,
        150
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "40719114-6df6-47b5-ba76-ff7f5dbf16db",
              "name": "email",
              "type": "string",
              "value": "={{ $json.emails }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "59ef516b-9237-4085-9e88-a76608c0e70b",
      "name": "Extract File Data",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        240,
        150
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "id": "bfef804a-d87d-4f49-90c3-844ba010bf2d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        20
      ],
      "parameters": {
        "height": 120,
        "content": "## Start Workflow\nCopy the webhook URL and use it in your app or API client (like Postman)."
      },
      "typeVersion": 1
    },
    {
      "id": "ff6f02b4-0495-43d3-b6b6-a11cf0dd4ceb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        320
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 100,
        "content": "## Change Input File Format\nChange file format if needed in Extract File Data Node."
      },
      "typeVersion": 1
    },
    {
      "id": "4e23de5c-85a4-40cb-94a1-6216a820bdad",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 140,
        "content": "## Change Field Name\nChange Data Header name if needed in Parse Data Node.\n\ncurrent -> emails"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract File Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace Me": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Contact": {
      "main": [
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Contact": {
      "main": [
        [
          {
            "node": "If contact exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Search Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract File Data": {
      "main": [
        [
          {
            "node": "Parse Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If contact exists": {
      "main": [
        [
          {
            "node": "Delete Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}