{
  "name": "Archive HR and legal documents with UploadToURL, Google Drive and Airtable",
  "nodes": [
    {
      "id": "2b43c48f-48fd-449d-89d8-4350be2d3f4b",
      "name": "📋 Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        -1248
      ],
      "parameters": {
        "width": 640,
        "height": 1600,
        "content": "# 🗂️ Legal & Compliance Document Archiving\n\n**The problem this solves:**\nHR managers receive signed contracts via email, WhatsApp, or phone scans — then manually rename files, drag them into the right"
      }
    },
    {
      "id": "56ea1858-57e2-40f4-8d80-de36f8fdd700",
      "name": "Entry & Duplicate Check",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -128
      ],
      "parameters": {
        "width": 500,
        "height": 502,
        "content": "## 🚪 Entry, Validation & Duplicate Check\n**Nodes:** Webhook → Validate & Enrich → Airtable Duplicate Check → IF Duplicate?\n\n- Accepts `POST` with employee metadata + either `fileUrl` or binary PDF/ima"
      }
    },
    {
      "id": "7adcde7a-ad34-4f2f-b26c-3e6deed5d9b6",
      "name": "Upload Chain",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -208
      ],
      "parameters": {
        "width": 500,
        "height": 780,
        "content": "## ☁️ Upload to URL → Google Drive\n**Nodes:** Has Remote URL? → Upload to URL (×2) → Extract Doc URL → Get/Create Drive Folder → Upload to Drive\n\n- Native **Upload to URL** node hosts the file first —"
      }
    },
    {
      "id": "c4495c99-6e3b-4753-a4ec-b8498d447661",
      "name": "Airtable Update",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3936,
        -192
      ],
      "parameters": {
        "width": 500,
        "height": 770,
        "content": "## 🗃️ Airtable Update\n**Nodes:** Airtable - Find Employee → Airtable - Update Record\n\n- `Find Employee` searches by `Employee ID` field first, falls back to name match\n- `Update Record` ticks `Contrac"
      }
    },
    {
      "id": "fd814fd6-732a-407d-896f-c5953038a326",
      "name": "Notification & Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4480,
        -160
      ],
      "parameters": {
        "width": 500,
        "height": 728,
        "content": "## 📧 Notification & Response\n**Nodes:** Send Confirmation Email → Build Final Response → Respond to Webhook\n\n- Sends a confirmation email to the HR manager (always) and optionally to the employee if `"
      }
    },
    {
      "id": "01cd1834-06a3-4431-bcac-56a665891e3a",
      "name": "Error & Conflict Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        656
      ],
      "parameters": {
        "width": 460,
        "height": 415,
        "content": "## ⚠️ Error & Conflict Handling\n**Nodes:** Duplicate Response (409) → Error Handler → Error Response (400)\n\n- `409 Conflict` is returned immediately if a contract already exists for the employee — pre"
      }
    },
    {
      "id": "5891f4a4-2d75-4783-af17-f312874287ed",
      "name": "Webhook - Receive Contract",
      "type": "n8n-nodes-base.webhook",
      "position": [
        688,
        240
      ]
    },
    {
      "id": "05264ff6-76ae-4def-aba1-e88cf91e62c8",
      "name": "Validate & Enrich Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        912,
        240
      ]
    },
    {
      "id": "aa8b3b42-5bc3-4a02-ba8f-5e2d85642f3c",
      "name": "Airtable - Duplicate Check",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1120,
        240
      ]
    },
    {
      "id": "51a5a374-b4d9-45ab-8166-55dea3242ee4",
      "name": "IF Duplicate Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        1344,
        240
      ]
    },
    {
      "id": "ec542ad4-017f-4e4a-a5c5-093374be5b1f",
      "name": "Respond - 409 Duplicate",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1552,
        128
      ]
    },
    {
      "id": "adbf5a1e-f466-412e-92a5-f55ded178cf8",
      "name": "Has Remote URL?",
      "type": "n8n-nodes-base.if",
      "position": [
        1552,
        352
      ]
    },
    {
      "id": "2c1a9f2b-46a4-4491-8149-e8ff23b21881",
      "name": "Upload to URL - Remote",
      "type": "n8n-nodes-uploadtourl.uploadToUrl",
      "position": [
        1760,
        224
      ]
    },
    {
      "id": "7fbca76a-eda4-48b8-9c44-400214202fe4",
      "name": "Upload to URL - Binary",
      "type": "n8n-nodes-uploadtourl.uploadToUrl",
      "position": [
        1760,
        464
      ]
    },
    {
      "id": "334da8a8-b8b9-4c45-9a33-ab93f64a6ced",
      "name": "Extract CDN URL",
      "type": "n8n-nodes-base.code",
      "position": [
        1984,
        352
      ]
    },
    {
      "id": "e82aac5b-6551-4415-9e87-288205dd1e68",
      "name": "Drive - Find Employee Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2208,
        240
      ]
    },
    {
      "id": "0ca63735-0c28-4ae3-a54c-dd0fe1dba37d",
      "name": "Resolve Folder ID",
      "type": "n8n-nodes-base.code",
      "position": [
        2432,
        240
      ]
    },
    {
      "id": "61329861-d0c7-415b-99b4-4b7a1cca5b41",
      "name": "Needs New Folder?",
      "type": "n8n-nodes-base.if",
      "position": [
        2640,
        240
      ]
    },
    {
      "id": "f82d1330-66de-4517-ac66-925df674384e",
      "name": "Drive - Create Employee Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2864,
        128
      ]
    },
    {
      "id": "cae0e67c-2fd0-4c8a-a3b8-0ddc5a455d7f",
      "name": "Merge Folder ID",
      "type": "n8n-nodes-base.code",
      "position": [
        3088,
        240
      ]
    },
    {
      "id": "cf175356-ab80-4d3e-a24e-5ca30310f6c2",
      "name": "Drive - Upload Document",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        3312,
        240
      ]
    },
    {
      "id": "ce49884a-6f07-41a5-b1ff-4ff323160002",
      "name": "Airtable - Find Employee Record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        3520,
        240
      ]
    },
    {
      "id": "9cca6163-dc9d-46ca-9531-fdfe6fc031fe",
      "name": "Prepare Airtable Update",
      "type": "n8n-nodes-base.code",
      "position": [
        3744,
        240
      ]
    },
    {
      "id": "90abc179-346a-4a82-97e7-6c2bc7c9fdbc",
      "name": "Airtable Record Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        3968,
        240
      ]
    },
    {
      "id": "57d9299a-20e1-4075-b2d2-2d31f3102ca7",
      "name": "Airtable - Update Existing Record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4192,
        128
      ]
    },
    {
      "id": "30b1753c-763c-4b50-9905-2756f6e85bba",
      "name": "Airtable - Create New Record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4192,
        368
      ]
    },
    {
      "id": "c92fc87d-1dc2-423e-971e-3b3d6b548759",
      "name": "Merge Airtable Result",
      "type": "n8n-nodes-base.code",
      "position": [
        4400,
        240
      ]
    },
    {
      "id": "c69bd238-b672-4de2-80e7-64548b2f1fba",
      "name": "Send Confirmation Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        4624,
        240
      ]
    },
    {
      "id": "44c9e268-f8f9-4e76-93c1-f3e92324145f",
      "name": "Build Final Response",
      "type": "n8n-nodes-base.code",
      "position": [
        4848,
        240
      ]
    },
    {
      "id": "42c588d7-d455-4357-9fc1-9d16ac39a101",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        5072,
        240
      ]
    },
    {
      "id": "5de2d9b8-930f-4837-8d83-34c75eabf316",
      "name": "Error Handler",
      "type": "n8n-nodes-base.code",
      "position": [
        1248,
        928
      ]
    },
    {
      "id": "6dddfd8d-2de7-4a97-8806-e8a16c5e262b",
      "name": "Respond with Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1456,
        928
      ]
    }
  ],
  "connections": {
    "Error Handler": {
      "main": [
        [
          {
            "node": "Respond with Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract CDN URL": {
      "main": [
        [
          {
            "node": "Drive - Find Employee Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Remote URL?": {
      "main": [
        [
          {
            "node": "Upload to URL - Remote",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload to URL - Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Folder ID": {
      "main": [
        [
          {
            "node": "Drive - Upload Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs New Folder?": {
      "main": [
        [
          {
            "node": "Drive - Create Employee Folder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resolve Folder ID": {
      "main": [
        [
          {
            "node": "Needs New Folder?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Final Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Duplicate Exists?": {
      "main": [
        [
          {
            "node": "Respond - 409 Duplicate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Has Remote URL?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Airtable Result": {
      "main": [
        [
          {
            "node": "Send Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to URL - Binary": {
      "main": [
        [
          {
            "node": "Extract CDN URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to URL - Remote": {
      "main": [
        [
          {
            "node": "Extract CDN URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable Record Exists?": {
      "main": [
        [
          {
            "node": "Airtable - Update Existing Record",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Airtable - Create New Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Drive - Upload Document": {
      "main": [
        [
          {
            "node": "Airtable - Find Employee Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Airtable Update": {
      "main": [
        [
          {
            "node": "Airtable Record Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Confirmation Email": {
      "main": [
        [
          {
            "node": "Build Final Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate & Enrich Payload": {
      "main": [
        [
          {
            "node": "Airtable - Duplicate Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Duplicate Check": {
      "main": [
        [
          {
            "node": "IF Duplicate Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - Receive Contract": {
      "main": [
        [
          {
            "node": "Validate & Enrich Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Create New Record": {
      "main": [
        [
          {
            "node": "Merge Airtable Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Drive - Find Employee Folder": {
      "main": [
        [
          {
            "node": "Resolve Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Drive - Create Employee Folder": {
      "main": [
        [
          {
            "node": "Merge Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Find Employee Record": {
      "main": [
        [
          {
            "node": "Prepare Airtable Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Update Existing Record": {
      "main": [
        [
          {
            "node": "Merge Airtable Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}