{
  "name": "Datavej: B2B lead list from CVR",
  "nodes": [
    {
      "id": "14a3e8d6-335d-5d36-83a6-26d70bc94a38",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -160
      ],
      "parameters": {
        "content": "## Datavej setup\n1. Create an API key at https://datavej.dk/dashboard#keys.\n2. Open the **Datavej** node, choose **Bearer Auth** and create a credential with the key as the token.\n   Prefer signing in? Switch Authentication to **MCP OAuth2** and connect: n8n registers itself and you approve it in the browser.\n3. Change industry and kommune in **Search criteria**, then click **Execute workflow**. The CSV is on the last node.\n\nGuide: https://datavej.dk/n8n\n\nCompanies that opted out of direct marketing (reklamebeskyttelse) are left out.",
        "width": 440,
        "height": 380
      }
    },
    {
      "id": "a909bad4-2b0b-5edf-a573-a4687f6932e3",
      "name": "Run",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "0a1142e0-45a6-51f8-887d-6dc8864e6158",
      "name": "Search criteria",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "67f5bfc8-4d5a-5a26-8586-4572a74ad22e",
              "name": "industry",
              "value": "tømrer",
              "type": "string"
            },
            {
              "id": "366c4bb6-2c77-5a71-8652-f744f94e2212",
              "name": "kommune",
              "value": "Aarhus",
              "type": "string"
            },
            {
              "id": "6bf3daba-745d-59c5-8800-39ab0097116a",
              "name": "min_employees",
              "value": 5,
              "type": "number"
            },
            {
              "id": "a0eaabe7-4dbe-59a1-8751-5aa6b20c9f90",
              "name": "limit",
              "value": 25,
              "type": "number"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "72aa3a01-c168-5a20-a4ba-b16ee5849782",
      "name": "Datavej",
      "type": "@n8n/n8n-nodes-langchain.mcpClient",
      "typeVersion": 1.1,
      "position": [
        440,
        0
      ],
      "parameters": {
        "serverTransport": "httpStreamable",
        "endpointUrl": "https://datavej.dk/mcp",
        "authentication": "bearerAuth",
        "tool": {
          "__rl": true,
          "mode": "id",
          "value": "company_search"
        },
        "inputMode": "json",
        "jsonInput": "={{ JSON.stringify({ industry: $json.industry, kommune: $json.kommune, min_employees: $json.min_employees, exclude_ad_protected: true, limit: $json.limit }) }}",
        "options": {}
      }
    },
    {
      "id": "07eefc9e-e833-593a-8c36-0b5cc10e8c94",
      "name": "One item per company",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ],
      "parameters": {
        "jsCode": "// company_search returns { total, shown, results: [...], notes } as JSON in the first content block.\nconst out = [];\nfor (const item of $input.all()) {\n  const first = (item.json.content || [])[0];\n  const data = first && typeof first.text === 'object' ? first.text : item.json.structuredContent || {};\n  for (const row of data.results || []) out.push({ json: row });\n}\nreturn out;"
      }
    },
    {
      "id": "d0e55f6a-89c1-5bea-beb7-af62495f2451",
      "name": "CSV file",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        880,
        0
      ],
      "parameters": {
        "options": {
          "fileName": "datavej-leads.csv"
        }
      }
    }
  ],
  "connections": {
    "Run": {
      "main": [
        [
          {
            "node": "Search criteria",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search criteria": {
      "main": [
        [
          {
            "node": "Datavej",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Datavej": {
      "main": [
        [
          {
            "node": "One item per company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One item per company": {
      "main": [
        [
          {
            "node": "CSV file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
