> ## Documentation Index
> Fetch the complete documentation index at: https://www.datalegion.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> Enrich people and companies in n8n with the Data Legion node. Install, credentials, operations, output, errors, and using the node as an AI Agent tool.

The Data Legion node brings person and company enrichment, plus free data cleaning, email hashing, and validation, into [n8n](https://n8n.io) workflows. It is an n8n community node, published as [`n8n-nodes-datalegion`](https://www.npmjs.com/package/n8n-nodes-datalegion), and it can run as a regular workflow step or as a tool for n8n's AI Agent.

<Note>
  The node is not in n8n's nodes panel yet. It is in n8n's review, and this page describes it ahead of launch. On a self-hosted instance you can install it by name now, as described under [Install](#install). To talk about access, email [support@datalegion.ai](mailto:support@datalegion.ai).
</Note>

## Prerequisites

* An n8n instance, on n8n Cloud or self-hosted
* A Data Legion API key, from [API Keys](https://www.datalegion.ai/dashboard/api-keys) in the dashboard

## Install

On n8n Cloud and self-hosted n8n, open the nodes panel (press **+** or **N**), search for **Data Legion**, pick it under **More from the community**, and select **Install**. The instance owner or an admin installs it once; every member can then use it.

On a self-hosted instance you can also install it by name: **Settings > Community nodes > Install**, then enter `n8n-nodes-datalegion`.

## Credentials

Add a **Data Legion API** credential and paste your API key. n8n checks the key against `GET /credits`, which is free, and shows **Connection tested successfully** when it works.

To try a workflow without spending credits, turn on **Sandbox Mode** in the credential (node 0.2.0+). Enrich then returns [sample records](/docs/api-reference/sandbox) with every field a real record has, and uses no credits. Turn it off for real lookups. If your API key is limited to certain endpoints, add `/sandbox/person/enrich` and `/sandbox/company/enrich` to it.

## Operations

| Resource | Operation | Endpoint | Billing |
| - | - | - | - |
| Person | Enrich | `POST /person/enrich` | Per matched record, under your plan. A no-match is free. |
| Company | Enrich | `POST /company/enrich` | Per matched record, under your plan. A no-match is free. |
| Utility | Clean Data | `POST /utility/clean` | Free |
| Utility | Hash Email | `POST /utility/hash/email` | Free |
| Utility | Validate Data | `POST /utility/validate` | Free |

## Enrich

Enrich looks up one record per input item. Add the identifiers you have under **Identifiers**; expressions work, so you can map fields from an earlier step.

| Resource | Identifiers |
| - | - |
| Person | Email, Phone, Social Profile URL, Full Name (or First and Last Name) with one more detail such as Company, Job Title, School, or location, Birth Date, Email Hash, LinkedIn ID, Data Legion ID |
| Company | Domain, Company Name, Social Profile URL, Ticker Symbol, LinkedIn ID, Data Legion ID |

A domain matches a company more reliably than a name. A birth date can be a full date, a year and month, or a year (`1985-03-15`, `1985-03` or `1985`). Under **Options**:

* **Minimum Match Confidence** drops matches below `high`, `moderate`, or `low` confidence.
* **Required Fields** takes comma-separated fields a match must have, such as `work_email` or `phones.type:mobile` for a person and `domain,socials`, `type:public` or `socials.network:linkedin` for a company. A match without them counts as a no-match.
* **Industry** (company only) narrows a match on company name, for example `software development`. It isn't a lookup on its own.

### Output

Every input item produces one output item, so a list keeps every row:

```json theme={null}
{
  "matched": true,
  "legion_id": "d38e32b2-0bd3-50a6-a236-3f0f8627ca6b",
  "domain": "hubspot.com",
  "industry": "software development",
  "match_metadata": {
    "matched_on": ["domain"],
    "match_type": "exact",
    "match_confidence": "high"
  }
}
```

The fields are the person or company record from the [Person Schema](/docs/person-data/schema) or [Company Schema](/docs/company-data/schema), plus `matched: true` and `match_metadata`. When nothing matches, the item is `{ "matched": false }`. Route the two with an **If** node on `matched`.

## Clean, Hash, and Validate

* **Clean Data** normalizes emails, phone numbers, names, profile URLs, domains, and the other fields you add. Set **Default Phone Region** (for example `US`) for numbers without a country code.
* **Hash Email** normalizes an address and returns its SHA-256, SHA-1, and MD5 hashes.
* **Validate Data** checks contact and company fields and returns errors, warnings, and suggested fixes before you spend credits on enrichment.

See [Clean](/docs/api-reference/utility-clean), [Hash Email](/docs/api-reference/utility-hash-email), and [Validate](/docs/api-reference/utility-validate) for the response shapes.

## Using the Node as an AI Agent Tool

Connect the Data Legion node to an **AI Agent** node's **Tool** input. Choose the resource and operation, add the identifier the agent should fill, and select **Let the model define this parameter** on it. The agent then decides when to call the tool and with which value. For example, asked "What industry is hubspot.com in?", the agent calls Company Enrich with `hubspot.com` and answers from the record.

To give an assistant the whole Data Legion toolset outside n8n, use the [MCP Server](/docs/integrations/mcp-server).

## Errors and Rate Limits

The node shows the API's own error message. Running out of credits (402) or calling an endpoint the key isn't scoped to (403) says so, and an invalid key (401) points you to the credential. Invalid input (400 or 422) points you to the values mapped into the node, and a temporary server error (5xx) suggests running again or turning on **Retry On Fail**.

Enrich and the utilities each allow 100 requests per minute. The node sends one request per item, so a long list can reach the limit and get a 429. Turn on **Retry On Fail** in the node's settings, or split the list with **Loop Over Items** and a **Wait** node. With **On Error** set to continue, a failed item comes out as `{ "error": "..." }` and the rest keep going.

See [Rate Limiting](/docs/api-reference/overview#rate-limiting) for details.

## The Node or the Data Legion API

The node covers enrichment and the free utilities inside n8n, one record per item. Search, natural-language discovery, and bulk delivery are on the [Data Legion API](/docs/api-reference/overview), which n8n's **HTTP Request** node can call with the same API key in an `API-Key` header.

## Related

* [`n8n-nodes-datalegion` on npm](https://www.npmjs.com/package/n8n-nodes-datalegion)
* [Source on GitHub](https://github.com/datalegion-ai/datalegion-n8n)
* [Person Enrichment API](/docs/api-reference/person-enrichment)
* [Company Enrichment API](/docs/api-reference/company-enrichment)
* [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.