AutomationFlowsData & Sheets › Domain to Email Extraction Using Apollo API

Domain to Email Extraction Using Apollo API

ByHueston @hueston on n8n.io

Sales professionals looking to build lead lists from target company domains Business development teams conducting outreach campaigns Marketers building contact databases for account-based marketing Recruiters searching for potential candidates at specific companies Anyone…

Event trigger★★★★☆ complexity9 nodesGoogle SheetsHTTP Request
Data & Sheets Trigger: Event Nodes: 9 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #3581 — we link there as the canonical source.

This workflow follows the Google Sheets → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "E4K85OV19sy8Jrly",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Domain -> Email Extraction using Apollo API copy",
  "tags": [],
  "nodes": [
    {
      "id": "02646c75-dad3-4b21-8203-e86732374a2c",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -400,
        -60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "69175622-b2fb-4a56-83bf-a55290f1c725",
      "name": "Loop Targets",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        40,
        -60
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5e6af8ff-2bc1-44b4-9523-3e55a785ee4d",
      "name": "Pull Target Domains",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -180,
        -60
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o/edit#gid=0",
          "cachedResultName": "Target Domains"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o/edit?usp=drivesdk",
          "cachedResultName": "Apollo Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "884b3766-8d4b-43a3-8a14-e3eee1a3d678",
      "name": "Get People By Domain",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        -60
      ],
      "parameters": {
        "url": "https://api.apollo.io/v1/mixed_people/search",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"q_organization_domains_list\": [\"{{ $json['Domain To Enrich'] }}\"],\n  \"per_page\": 10,\n  \"page\": 1\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "Your  API KEY "
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "df77689b-ccd3-4638-a981-4cf13fbf8a70",
      "name": "Clean Up Results",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        -60
      ],
      "parameters": {
        "jsCode": "// Function node code\nconsole.log('Initial data:', JSON.stringify(items, null, 2));\n\n// Get the first item since n8n usually wraps data in an array\nconst data = items[0].json;\nconsole.log('Data structure:', JSON.stringify(data, null, 2));\n\n// Now process the people data\nconst people = data.people || [];\n\ntry {\n  return people.map(person => {\n    console.log('Processing person:', JSON.stringify(person, null, 2));\n    return {\n      json: {\n        firstName: person.first_name || '',\n        lastName: person.last_name || '',\n        email: person.email || '',\n        websiteUrl: person.website_url || '',\n        linkedinUrl: person.linkedin_url || '',\n        twitterUrl: person.twitter_url || '',\n        facebookUrl: person.facebook_url || '',\n        phone: person.primary_phone?.number || '',\n        company: {\n          name: person.company_name || '',\n          domain: person.primary_domain || '',\n          foundedYear: person.founded_year || '',\n          logo: person.logo_url || ''\n        },\n        professional: {\n          departments: person.departments || [],\n          seniority: person.seniority || '',\n          functions: person.functions || []\n        }\n      }\n    };\n  });\n} catch (error) {\n  console.log('Error occurred. Full items:', JSON.stringify(items, null, 2));\n  throw new Error(`Error processing data: ${error.message}`);\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "bc0f01b0-3225-4023-9e21-0bcebab00808",
      "name": "Loop Over Results",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        680,
        -60
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "65533eb2-a738-4cf3-9cbc-480a911e4fb2",
      "name": "Get Person Info",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        920,
        -60
      ],
      "parameters": {
        "url": "=https://api.apollo.io/api/v1/people/match?first_name={{ $json.firstName }}&last_name={{ $json.lastName }}&domain={{ $('Get People By Domain').item.json.breadcrumbs[0].value[0] }}&reveal_personal_emails=false&reveal_phone_number=false ",
        "method": "POST",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "Your API Key"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c369c7e-e79b-4bf1-97d4-25abac4256db",
      "name": "Clean Up",
      "type": "n8n-nodes-base.code",
      "position": [
        1140,
        -60
      ],
      "parameters": {
        "jsCode": "// Function node to extract specific fields from Apollo response\ntry {\n    const results = items.map(item => {\n        const person = item.json.person; // Access the person object directly\n        \n        return {\n            json: {\n                firstName: person.first_name || '',\n                lastName: person.last_name || '',\n                email: person.email || '',\n                linkedinUrl: person.linkedin_url || '',\n                title: person.title || '',\n                twitter: person.twitter_url || '',\n                facebook: person.facebook_url || '',\n                organizationName: person.employment_history?.[0]?.organization_name || '', // Get current organization from employment history\n                headline: person.headline || '',\n                photoUrl: person.photo_url || ''\n            }\n        };\n    });\n\n    console.log(`Successfully processed ${results.length} records`);\n    return results;\n\n} catch (error) {\n    console.error('Error processing data:', error);\n    throw new Error(`Failed to process data: ${error.message}`);\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "f0eaa1e7-299f-4ec8-ae26-90bbe1483a1e",
      "name": "Results To Results Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1340,
        -60
      ],
      "parameters": {
        "columns": {
          "value": {
            "Email": "={{ $json.email }}",
            "Title": "={{ $json.title }}",
            "Company": "={{ $('Loop Targets').item.json['Domain To Enrich'] }}",
            "Last Name": "={{ $json.lastName }}",
            "Linkedin ": "={{ $json.linkedinUrl }}",
            "First Name": "={{ $json.firstName }}"
          },
          "schema": [
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Linkedin ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Linkedin ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 308352805,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o/edit#gid=308352805",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qSlCPA-FqrQZUS7DIqYaZbhdhxZDxIM3xYrswJKEZ-o/edit?usp=drivesdk",
          "cachedResultName": "Apollo Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3fe93ef2-9ba0-474e-9b44-dbb9f9fa4fd8",
  "connections": {
    "Clean Up": {
      "main": [
        [
          {
            "node": "Results To Results Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Targets": {
      "main": [
        [],
        [
          {
            "node": "Get People By Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Person Info": {
      "main": [
        [
          {
            "node": "Clean Up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Up Results": {
      "main": [
        [
          {
            "node": "Loop Over Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Results": {
      "main": [
        [
          {
            "node": "Loop Targets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Person Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Target Domains": {
      "main": [
        [
          {
            "node": "Loop Targets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get People By Domain": {
      "main": [
        [
          {
            "node": "Clean Up Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Results To Results Sheet": {
      "main": [
        [
          {
            "node": "Loop Over Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Pull Target Domains",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Sales professionals looking to build lead lists from target company domains Business development teams conducting outreach campaigns Marketers building contact databases for account-based marketing Recruiters searching for potential candidates at specific companies Anyone…

Source: https://n8n.io/workflows/3581/ — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

This template is ideal for solo store owners, eCommerce marketers, automation beginners, or anyone using Shopify and Gmail who wants to recover lost revenue without coding.

HTTP Request, Gmail, Twilio +3
Data & Sheets

PCN. Uses googleSheets, httpRequest, @n-octo-n/n8n-nodes-json-database, itemLists. Event-driven trigger; 60 nodes.

Google Sheets, HTTP Request, @N Octo N/N8N Nodes Json Database +3
Data & Sheets

The workflow automates the process of gathering extensive keyword data for a "Main Keyword." It starts by reading initial parameters from a Google Sheets template, creates a new dedicated Google Sheet

Google Sheets, Google Drive, HTTP Request
Data & Sheets

🔥 March Sale – n8n Community Members Get ideoGener8r for Just $27! (Reg. $47) Use Coupon Code: (Valid until 3/31/2025 for n8n community members)

HTTP Request, Google Drive, Google Sheets
Data & Sheets

📄 Documentation: Notion Guide

Google Sheets, Google Drive, HTTP Request +2