{
  "name": "LookupLab - phone list review",
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "nodes": [
    {
      "id": "start",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "input",
      "name": "Your phone list",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ],
      "parameters": {
        "jsCode": "// Replace with numbers you are authorized to process. E.164 preserves country codes.\nconst numbers = ['+12025550123'];\nreturn [...new Set(numbers.map(n => String(n).trim()).filter(Boolean))].slice(0, 100).map(phone => ({ json: { phone } }));"
      }
    },
    {
      "id": "lookup",
      "name": "LookupLab phone",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://lookuplab.io/api/v1/phone/",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $json.phone }}"
            }
          ]
        },
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 250
            }
          },
          "timeout": 30000
        }
      }
    },
    {
      "id": "results",
      "name": "Review results",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        0
      ],
      "parameters": {
        "jsCode": "return $input.all().map(item => {\n  const { data: d, meta } = item.json;\n  if (!d || typeof meta?.charged !== 'number') throw new Error('Unexpected LookupLab response');\n  return { json: { number: d.number || d.input || '', valid: d.valid === true, line_type: d.line_type || 'unknown', carrier: d.carrier || '', country: d.country || '', credits_charged: meta.charged, review: d.error ? 'lookup_error' : d.valid !== true ? 'invalid' : d.line_type === 'mobile' ? 'mobile_check_consent' : 'review_channel' } };\n});"
      }
    },
    {
      "id": "note",
      "name": "Read before running",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        220,
        -260
      ],
      "parameters": {
        "content": "## Connect your account\n1. Replace the sample number in Your phone list.\n2. In LookupLab phone select a Header Auth credential: Authorization = Bearer YOUR_KEY.\n3. Run a small sample. This workflow only enriches data; it does not contact people.\nPhone checks cost 1-3 credits. Mobile line type is not consent or guaranteed SMS delivery.\nHTTP errors stop the run. Inspect partial execution before replaying.",
        "height": 220,
        "width": 630
      }
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Your phone list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your phone list": {
      "main": [
        [
          {
            "node": "LookupLab phone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LookupLab phone": {
      "main": [
        [
          {
            "node": "Review results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
