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

# Lead Enrichment & CRM Integration

> Automatically enrich leads with brand data, logos, and company information

<img src="https://mintcdn.com/branddev/JTvSrAMAd7UkFxMq/guides/image-6.png?fit=max&auto=format&n=JTvSrAMAd7UkFxMq&q=85&s=2f2b59c4e2737c40a9ad88f30e2cff75" alt="image of transactions being enriched demo" width="974" height="952" data-path="guides/image-6.png" />

## Overview

Transform basic lead information (email or domain) into rich company profiles with logos, colors, industry classification, and social links—all automatically.

When your users interact with organizations in your CRM, they typically start with minimal data: an email address, a company name, or a domain. Context.dev enriches these records with:

* **Company logos** for visual recognition in contact lists
* **Phone numbers and addresses** for complete contact profiles
* **Social media links** (LinkedIn, X, etc.) for outreach
* **Industry classification** for segmentation and reporting
* **Company descriptions** for context at a glance

### Prerequisites

1. A [Context.dev](https://context.dev) API key
2. A CRM or contact management application

## Implementation

### 1. Trigger Enrichment

Enrich lead data when a new contact or organization is created. Extract the domain from the user's email or use the company domain directly:

```typescript theme={null}
import ContextDev from "context.dev";

const client = new ContextDev({ apiKey: process.env.CONTEXT_DEV_API_KEY });

async function enrichLead(email: string) {
  // Fetch brand data by email - automatically extracts domain
  const { brand } = await client.brand.retrieveByEmail({ email });
  
  // Select logo based on your UI theme
  const lightLogo = brand.logos?.find(logo => logo.mode === 'light')?.url;
  const darkLogo = brand.logos?.find(logo => logo.mode === 'dark')?.url;
  
  return {
    companyName: brand.title,
    description: brand.description,
    phone: brand.phone,
    domain: brand.domain,
    logo: lightLogo || brand.logos?.[0]?.url, // Use light logo or fallback to first available
    logoDark: darkLogo, // Optional: store both for theme switching
    address: brand.address,
    socials: brand.socials,
    industry: brand.industries
  };
}
```

<Note>
  The [Retrieve by Email endpoint](/api-reference/retrieve-brand/retrieve-brand-data-by-email-address) automatically rejects disposable and free email providers (Gmail, Yahoo, etc.) to avoid false enrichments.
</Note>

<Tip>
  Use the `mode` field on logos to select appropriate versions for light or dark mode UIs. See the [Brand API reference](/api-reference/retrieve-brand/retrieve-brand-data-by-domain) for all available fields and filtering options.
</Tip>

### 2. Map to CRM Fields

Map Context.dev response fields to your CRM's data model:

| Context.dev Field                   | CRM Field           |
| ----------------------------------- | ------------------- |
| `title`                             | Company Name        |
| `description`                       | Company Description |
| `phone`                             | Phone Number        |
| `logos[0].url`                      | Company Logo        |
| `address.street`, `city`, `country` | Address             |
| `socials` (type: linkedin)          | LinkedIn URL        |
| `socials` (type: x)                 | X (Twitter) URL     |
| `industries`                        | Industry/Segment    |

### 3. Display Enriched Profiles

Use the enriched data to create visually rich organization profiles:

```typescript theme={null}
function buildOrganizationProfile(enrichedData: any) {
  return {
    header: {
      logo: enrichedData.logo || '/placeholder-company.svg',
      name: enrichedData.companyName,
      tagline: enrichedData.description?.slice(0, 100)
    },
    contact: {
      phone: enrichedData.phone,
      address: formatAddress(enrichedData.address)
    },
    social: enrichedData.socials?.reduce((acc: any, s: any) => {
      acc[s.type] = s.url;
      return acc;
    }, {})
  };
}
```

## Best Practices

### 1. Enrich on Create, Not on View

> Trigger enrichment when leads are created or imported, not every time a profile is viewed. Cache the enriched data in your database.

### 2. Handle Missing Data

> Not all companies have complete profiles. Display graceful fallbacks for missing logos, phone numbers, or addresses.

### 3. Allow Manual Overrides

> Let users edit enriched fields. Their corrections should take precedence over API data on future views.

## Related Resources

<CardGroup cols={2}>
  <Card title="Retrieve by Email" icon="envelope" href="/api-reference/retrieve-brand/retrieve-brand-data-by-email-address">
    Enrich leads from email addresses
  </Card>

  <Card title="Retrieve by Domain" icon="globe" href="/api-reference/retrieve-brand/retrieve-brand-data-by-domain">
    Enrich from company domains
  </Card>

  <Card title="NAICS Classification" icon="industry" href="/api-reference/industry-classification/retrieve-naics-code-for-any-brand">
    Classify companies by industry
  </Card>

  <Card title="Onboarding Flows" icon="user-plus" href="/guides/use-cases/onboarding-flows">
    Pre-fill signup forms with brand data
  </Card>
</CardGroup>
