{
  "id": "htrcf3296e87cf12",
  "name": "HowToRomania · Verify Romanian companies by CUI (Google Sheets)",
  "nodes": [
    {
      "parameters": {
        "content": "# Verify Romanian companies by CUI\nReads CUIs from a Google Sheet, looks each one up in ANAF data via HowToRomania (`GET /v1/company/{cui}`, 1 credit), and writes back name, VAT status, active status and e-Factura registration.\n\n## Setup\n1. Credentials → New → **Header Auth**: Name `x-api-key`, Value = your HowToRomania key (free key with 100 credits: https://api.howtoromania.io/docs#quickstart).\n2. Select that credential in every *HowToRomania* HTTP node.\n3. Sheet columns (row 1): `cui`, `name`, `vat_id`, `vat_registered`, `active`, `e_factura`, `checked_at`, `check_status`.\n4. Set the sheet URL and tab in both Google Sheets nodes.\n\nAnswers are cached up to 6 h. Invalid CUIs and not-found are not billed.",
        "height": 420,
        "width": 520
      },
      "id": "2814de16-d414-5765-8e5f-190407d4d375",
      "name": "About",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -460,
        -140
      ]
    },
    {
      "parameters": {},
      "id": "810baff2-f80b-5e8c-a34a-a42ecaa9254d",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        100,
        0
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "6741ebf8-8d13-565d-87a7-c04464fd42e5",
      "name": "Every morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        100,
        200
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "REPLACE_WITH_YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Companies"
        },
        "options": {}
      },
      "id": "c7457222-6769-5a57-a586-406ec41b87ef",
      "name": "Read rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        340,
        100
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "cf79590d-37cf-5f9f-b8d5-c51429b50b57",
              "leftValue": "={{ String($json.cui ?? '').trim() }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "7baaa7a1-8a26-5834-b9ec-a73cd20b3339",
      "name": "Has CUI",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        560,
        100
      ]
    },
    {
      "parameters": {
        "url": "=https://api.howtoromania.io/v1/company/{{ encodeURIComponent(String($json.cui).trim()) }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true
            }
          }
        }
      },
      "id": "fbb318af-cbec-5ca0-b90d-9e2cdab3d042",
      "name": "HowToRomania: company lookup",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        100
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "HowToRomania API key"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Map the HowToRomania response onto sheet columns. Errors (400/404) are not billed.\nreturn $input.all().map((item, i) => {\n  const row = $('Has CUI').all()[i].json;\n  const r = item.json;               // fullResponse: { statusCode, headers, body }\n  const d = r.body && r.body.data;\n  const ok = r.statusCode === 200 && d;\n  return { json: {\n    row_number: row.row_number,\n    name: ok ? d.name : '',\n    vat_id: ok ? d.vatId : '',\n    vat_registered: ok ? String(d.vat.registered) : '',\n    active: ok ? String(d.status.active) : '',\n    e_factura: ok ? String(d.eFactura.registered) : '',\n    checked_at: new Date().toISOString(),\n    check_status: ok ? 'ok' : `error ${r.statusCode}: ${(r.body && r.body.error && r.body.error.code) || 'unknown'}`,\n  } };\n});"
      },
      "id": "b552e752-11df-525d-aa90-b7d5a76f2368",
      "name": "Map fields",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1000,
        100
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "REPLACE_WITH_YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Companies"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "row_number"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "2a37c568-44b9-5a0a-897b-03b1d4338c2f",
      "name": "Write back",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1220,
        100
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Read rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every morning": {
      "main": [
        [
          {
            "node": "Read rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read rows": {
      "main": [
        [
          {
            "node": "Has CUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has CUI": {
      "main": [
        [
          {
            "node": "HowToRomania: company lookup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HowToRomania: company lookup": {
      "main": [
        [
          {
            "node": "Map fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map fields": {
      "main": [
        [
          {
            "node": "Write back",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}