{
  "name": "ScanKit: Client document secure intake",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "scankit-secure-intake",
        "responseMode": "onReceived",
        "responseData": "noData",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "b12f3e0c-b0f0-48a8-a503-23de5c0c4917",
      "name": "ScanKit Intake Webhook",
      "webhookId": "3495ba49-e443-4c05-8fe9-a11ad2ff1092"
    },
    {
      "parameters": {
        "jsCode": "// Normalize the ScanKit webhook envelope (client document intake).\n// ScanKit sends ONLY the cleaned scan (file scan.pdf + metadata JSON).\nconst item = { json: {}, binary: {} };\nlet meta = {};\nif (typeof $json.metadata === 'string') {\n  try { meta = JSON.parse($json.metadata); } catch (e) { meta = {}; }\n} else if ($json.metadata && typeof $json.metadata === 'object') {\n  meta = $json.metadata;\n} else {\n  meta = $json;\n}\nconst ts = meta.timestamp || new Date().toISOString();\nconst safeName = String(meta.scanner_name || 'client-intake').replace(/[^a-z0-9-_]/gi, '_').toLowerCase();\n// Fictional example values are used when the envelope is empty.\nitem.json = {\n  scanner_id: meta.scanner_id || 99,                        // fictional\n  scanner_name: meta.scanner_name || 'Client Intake',       // fictional\n  page_count: meta.page_count || 1,\n  timestamp: ts,\n  storage_key: ts + '_' + safeName, // key for your own storage\n};\nif ($binary && Object.keys($binary).length) {\n  item.binary.scan = $binary[Object.keys($binary)[0]];\n}\nreturn [item];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ],
      "id": "a8f62055-8bf8-4a2d-817e-35eac5ec53eb",
      "name": "Normalize ScanKit payload"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "=https://YOUR-SECURE-STORAGE.example/files/{{ $json.storage_key }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ key: $json.storage_key, note: \"Replace this node with your S3/Drive/database upload step.\" }) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "114139c9-631f-4d85-89f4-008802a8369a",
      "name": "Store PDF in your storage"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR-TRACKING-TABLE-ENDPOINT.example/rows",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ scanner_id: $json.scanner_id, scanner_name: $json.scanner_name, page_count: $json.page_count, timestamp: $json.timestamp, storage_key: $json.storage_key }) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ],
      "id": "b6a95239-f44a-4fdc-89db-5548002651dc",
      "name": "Insert metadata row"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR-NOTIFY-ENDPOINT.example/notify",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ subject: \"New client document received\", scanner_name: $json.scanner_name, page_count: $json.page_count, review_link: \"https://YOUR-TRACKING.example/rows/\" + $json.storage_key }) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ],
      "id": "a99acf90-d236-495d-b922-99b7e91cd1ef",
      "name": "Notify responsible person"
    },
    {
      "parameters": {
        "content": "Workflow template: secure client document intake.\n\n1. Hosted ScanKit scanner points at THIS workflow webhook URL.\n2. Webhook receives the cleaned scan only (file + metadata JSON).\n3. Replace the storage step (YOUR-SECURE-STORAGE) with your own S3/Drive/database upload.\n4. Point the metadata row and the notification at your tracking table and email/Slack.\n5. Test end to end and confirm the file landed in your storage.\n\nAll example values are fictional.",
        "height": 380,
        "width": 300
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        440,
        300
      ],
      "id": "397547d6-c6e8-42a5-817d-58c9919857c4",
      "name": "How to use"
    }
  ],
  "pinData": {},
  "connections": {
    "ScanKit Intake Webhook": {
      "main": [
        [
          {
            "node": "Normalize ScanKit payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize ScanKit payload": {
      "main": [
        [
          {
            "node": "Store PDF in your storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store PDF in your storage": {
      "main": [
        [
          {
            "node": "Insert metadata row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert metadata row": {
      "main": [
        [
          {
            "node": "Notify responsible person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "08f40891-bb92-4711-8b8f-ee322c08f39f",
  "meta": {},
  "id": "c3a337ba-0109-4a3a-a640-5ce3333b908e",
  "tags": []
}