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

# CrewAI

> Use Encrata as a tool in your CrewAI agents for email intelligence.

## Overview

[CrewAI](https://www.crewai.com) is a framework for orchestrating autonomous AI agents that collaborate on tasks. You can give your crew access to Encrata for email enrichment, validation, and breach checking.

## Installation

```bash theme={"dark"}
pip install crewai requests
```

## Define Encrata tools

```python theme={"dark"}
import requests
from crewai.tools import tool

ENCRATA_API_KEY = "YOUR_API_KEY"
BASE_URL = "https://encrata.com/api/agent"
HEADERS = {
    "Authorization": f"Bearer {ENCRATA_API_KEY}",
    "Content-Type": "application/json",
}

@tool("Lookup Email")
def lookup_email(email: str) -> dict:
    """Look up detailed intelligence about a person by their email address.
    Returns name, company, job role, industry, location, social profiles,
    breach history, and email validity. Costs 1 credit."""
    resp = requests.post(
        f"{BASE_URL}/lookup",
        headers=HEADERS,
        json={"email": email},
    )
    resp.raise_for_status()
    return resp.json()

@tool("Validate Email")
def validate_email(email: str) -> dict:
    """Validate whether an email address is deliverable, invalid,
    or disposable. Free — does not cost credits."""
    resp = requests.post(
        f"{BASE_URL}/validate",
        headers=HEADERS,
        json={"email": email},
    )
    resp.raise_for_status()
    return resp.json()

@tool("Check Breaches")
def check_breaches(email: str) -> dict:
    """Check if an email has been exposed in known data breaches.
    Returns breach count, affected services, and exposed data types.
    Free — does not cost credits."""
    resp = requests.post(
        f"{BASE_URL}/breaches",
        headers=HEADERS,
        json={"email": email},
    )
    resp.raise_for_status()
    return resp.json()
```

## Create agents and tasks

```python theme={"dark"}
from crewai import Agent, Task, Crew

researcher = Agent(
    role="Lead Researcher",
    goal="Gather detailed intelligence on people from their email addresses",
    backstory="You are a seasoned research analyst specializing in "
              "contact intelligence and due diligence.",
    tools=[lookup_email, validate_email, check_breaches],
    verbose=True,
)

analyst = Agent(
    role="Intelligence Analyst",
    goal="Analyze and summarize findings into actionable briefs",
    backstory="You synthesize raw data into clear, structured reports.",
    verbose=True,
)

research_task = Task(
    description="Look up the following email and gather all available intelligence: {email}",
    expected_output="Full enrichment data including name, company, role, socials, and breach exposure.",
    agent=researcher,
)

report_task = Task(
    description="Write a concise intelligence brief based on the research findings.",
    expected_output="A structured summary with key facts, risk indicators, and recommendations.",
    agent=analyst,
)

crew = Crew(
    agents=[researcher, analyst],
    tasks=[research_task, report_task],
    verbose=True,
)

result = crew.kickoff(inputs={"email": "satya@microsoft.com"})
print(result)
```

## Bulk research example

```python theme={"dark"}
emails = [
    "satya@microsoft.com",
    "tim@apple.com",
    "sundar@google.com",
]

for email in emails:
    result = crew.kickoff(inputs={"email": email})
    print(f"\n--- {email} ---")
    print(result)
```

## Next steps

* [API Reference](/api-reference/overview) — full endpoint documentation
* [MCP Server](/mcp-server) — connect via Model Context Protocol
* [Field glossary](/api-reference/fields) — all available response fields
