POST
/
api
/
v2
/
enrich
curl --request POST \
  --url https://api.buena.ai/api/v2/enrich \
  --header 'Content-Type: <content-type>' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "leads": [
    {}
  ],
  "enrichmentOptions": {
    "includePersonalInfo": true,
    "includeCompanyInfo": true,
    "includeSocialProfiles": true,
    "includeContactInfo": true
  }
}'
{
  "success": true,
  "data": {
    "enriched": [
      {
        "input": {
          "email": "john@techcorp.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "enrichedData": {
          "firstName": "John",
          "lastName": "Doe",
          "email": "john@techcorp.com",
          "alternativeEmails": ["j.doe@techcorp.com"],
          "phone": "+1-555-123-4567",
          "linkedinUrl": "https://linkedin.com/in/johndoe",
          "company": "Tech Corp",
          "title": "Senior Software Engineer",
          "location": "San Francisco, CA",
          "experience": "8 years",
          "skills": ["JavaScript", "React", "Node.js", "Python", "AWS"],
          "bio": "Experienced software engineer specializing in full-stack development and cloud architecture.",
          "companyInfo": {
            "name": "Tech Corp",
            "website": "https://techcorp.com",
            "industry": "Technology",
            "size": "100-500",
            "description": "Leading provider of enterprise software solutions.",
            "founded": "2010",
            "headquarters": "San Francisco, CA"
          },
          "socialProfiles": {
            "twitter": "https://twitter.com/johndoe",
            "github": "https://github.com/johndoe"
          }
        },
        "confidence": 0.95,
        "sources": ["apollo", "clearbit", "hunter"]
      }
    ],
    "failed": [],
    "creditsUsed": 1,
    "remainingCredits": 99
  }
}

Enrich Leads

Enhance your leads with comprehensive data from premium sources including Apollo, Clearbit, Hunter, and more. Get additional contact information, company details, social profiles, and professional background data.

Requires the leads:enrich permission. Each enrichment request consumes credits from your account.

Request

x-api-key
string
required

Your API key with leads:enrich permission

Content-Type
string
required

Must be application/json

Body Parameters

leads
array
required

Array of lead objects to enrich. At least one identifier (email, LinkedIn URL, or name + company) is required per lead.

enrichmentOptions
object

Configuration options for the enrichment process

Lead Input Formats

You can provide leads in various formats. The more information you provide, the better the enrichment results:

Examples

Basic Enrichment

curl -X POST "https://api.buena.ai/api/v2/enrich" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "leads": [
      {
        "email": "john@techcorp.com",
        "firstName": "John",
        "lastName": "Doe"
      }
    ],
    "enrichmentOptions": {
      "includePersonalInfo": true,
      "includeCompanyInfo": true,
      "includeContactInfo": true
    }
  }'

Bulk Enrichment

curl -X POST "https://api.buena.ai/api/v2/enrich" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "leads": [
      {
        "email": "john@techcorp.com"
      },
      {
        "linkedinUrl": "https://linkedin.com/in/janedoe"
      },
      {
        "firstName": "Bob",
        "lastName": "Smith",
        "company": "Startup Inc"
      }
    ]
  }'

Response

success
boolean

Always true for successful requests

data
object

Container for enrichment results and metadata

{
  "success": true,
  "data": {
    "enriched": [
      {
        "input": {
          "email": "john@techcorp.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "enrichedData": {
          "firstName": "John",
          "lastName": "Doe",
          "email": "john@techcorp.com",
          "alternativeEmails": ["j.doe@techcorp.com"],
          "phone": "+1-555-123-4567",
          "linkedinUrl": "https://linkedin.com/in/johndoe",
          "company": "Tech Corp",
          "title": "Senior Software Engineer",
          "location": "San Francisco, CA",
          "experience": "8 years",
          "skills": ["JavaScript", "React", "Node.js", "Python", "AWS"],
          "bio": "Experienced software engineer specializing in full-stack development and cloud architecture.",
          "companyInfo": {
            "name": "Tech Corp",
            "website": "https://techcorp.com",
            "industry": "Technology",
            "size": "100-500",
            "description": "Leading provider of enterprise software solutions.",
            "founded": "2010",
            "headquarters": "San Francisco, CA"
          },
          "socialProfiles": {
            "twitter": "https://twitter.com/johndoe",
            "github": "https://github.com/johndoe"
          }
        },
        "confidence": 0.95,
        "sources": ["apollo", "clearbit", "hunter"]
      }
    ],
    "failed": [],
    "creditsUsed": 1,
    "remainingCredits": 99
  }
}

Advanced Use Cases

1. CRM Integration Enrichment

async function enrichCRMContacts() {
  // Get contacts from your CRM that need enrichment
  const contacts = await getCRMContacts({ needsEnrichment: true });

  // Prepare leads for enrichment
  const leadsToEnrich = contacts.map((contact) => ({
    email: contact.email,
    firstName: contact.firstName,
    lastName: contact.lastName,
    company: contact.company,
  }));

  // Batch enrichment (max 50 per request)
  const batchSize = 50;
  const enrichedLeads = [];

  for (let i = 0; i < leadsToEnrich.length; i += batchSize) {
    const batch = leadsToEnrich.slice(i, i + batchSize);

    const response = await fetch("https://api.buena.ai/api/v2/enrich", {
      method: "POST",
      headers: {
        "x-api-key": process.env.BUENA_API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        leads: batch,
        enrichmentOptions: {
          includePersonalInfo: true,
          includeCompanyInfo: true,
          includeContactInfo: true,
        },
      }),
    });

    const data = await response.json();
    enrichedLeads.push(...data.data.enriched);

    console.log(
      `Enriched batch ${Math.floor(i / batchSize) + 1}: ${
        data.data.enriched.length
      } leads`
    );

    // Rate limiting
    await new Promise((resolve) => setTimeout(resolve, 1000));
  }

  // Update CRM with enriched data
  for (const enriched of enrichedLeads) {
    await updateCRMContact(enriched.input.email, enriched.enrichedData);
  }

  return enrichedLeads;
}

2. Lead Scoring with Enrichment

import requests

def enrich_and_score_leads(leads):
    """Enrich leads and calculate quality scores"""

    response = requests.post(
        'https://api.buena.ai/api/v2/enrich',
        headers={
            'x-api-key': os.getenv('BUENA_API_KEY'),
            'Content-Type': 'application/json'
        },
        json={
            'leads': leads,
            'enrichmentOptions': {
                'includePersonalInfo': True,
                'includeCompanyInfo': True
            }
        }
    )

    data = response.json()
    scored_leads = []

    for enriched in data['data']['enriched']:
        lead_data = enriched['enrichedData']
        score = calculate_lead_score(lead_data)

        scored_leads.append({
            **lead_data,
            'score': score,
            'confidence': enriched['confidence']
        })

    return sorted(scored_leads, key=lambda x: x['score'], reverse=True)

def calculate_lead_score(lead_data):
    """Calculate lead quality score based on enriched data"""
    score = 0

    # Company size scoring
    company_size = lead_data.get('companyInfo', {}).get('size', '')
    size_scores = {
        '1000+': 10,
        '500-1000': 8,
        '100-500': 6,
        '50-100': 4,
        '10-50': 2
    }
    score += size_scores.get(company_size, 0)

    # Title scoring
    title = lead_data.get('title', '').lower()
    senior_titles = ['ceo', 'cto', 'vp', 'director', 'head', 'senior', 'lead']
    if any(t in title for t in senior_titles):
        score += 5

    # Technology fit scoring
    skills = lead_data.get('skills', [])
    target_skills = ['python', 'javascript', 'aws', 'machine learning', 'api']
    skill_matches = sum(1 for skill in skills if any(target in skill.lower() for target in target_skills))
    score += skill_matches * 2

    # Contact info completeness
    if lead_data.get('phone'):
        score += 2
    if lead_data.get('linkedinUrl'):
        score += 2

    return min(score, 25)  # Cap at 25

# Example usage
leads_to_enrich = [
    {'email': 'john@techcorp.com'},
    {'email': 'jane@startup.io'},
    {'linkedinUrl': 'https://linkedin.com/in/bobsmith'}
]

scored_leads = enrich_and_score_leads(leads_to_enrich)
print("Top scoring leads:")
for lead in scored_leads[:5]:
    print(f"{lead['firstName']} {lead['lastName']} ({lead['company']}) - Score: {lead['score']}")

3. Real-time Enrichment for Forms

// Real-time enrichment as users fill out forms
class FormEnrichment {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.cache = new Map();
    this.enrichmentTimeout = null;
  }

  async onEmailChange(email) {
    // Debounce enrichment requests
    clearTimeout(this.enrichmentTimeout);

    this.enrichmentTimeout = setTimeout(async () => {
      try {
        const enrichedData = await this.enrichLead({ email });
        if (enrichedData) {
          this.autofillForm(enrichedData);
        }
      } catch (error) {
        console.log("Enrichment failed:", error.message);
      }
    }, 1000);
  }

  async enrichLead(leadData) {
    const cacheKey = JSON.stringify(leadData);
    if (this.cache.has(cacheKey)) {
      return this.cache.get(cacheKey);
    }

    const response = await fetch("https://api.buena.ai/api/v2/enrich", {
      method: "POST",
      headers: {
        "x-api-key": this.apiKey,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        leads: [leadData],
        enrichmentOptions: {
          includePersonalInfo: true,
          includeCompanyInfo: true,
        },
      }),
    });

    const data = await response.json();
    const enriched = data.data.enriched[0];

    if (enriched) {
      this.cache.set(cacheKey, enriched.enrichedData);
      return enriched.enrichedData;
    }

    return null;
  }

  autofillForm(enrichedData) {
    // Auto-fill form fields with enriched data
    const fieldMap = {
      firstName: enrichedData.firstName,
      lastName: enrichedData.lastName,
      company: enrichedData.company,
      title: enrichedData.title,
      phone: enrichedData.phone,
      linkedinUrl: enrichedData.linkedinUrl,
    };

    Object.entries(fieldMap).forEach(([fieldName, value]) => {
      const field = document.querySelector(`[name="${fieldName}"]`);
      if (field && !field.value && value) {
        field.value = value;
        field.dispatchEvent(new Event("change"));
      }
    });

    // Show enrichment success indicator
    this.showEnrichmentSuccess(enrichedData);
  }

  showEnrichmentSuccess(data) {
    const notification = document.createElement("div");
    notification.className = "enrichment-success";
    notification.innerHTML = `
      <div>✅ Auto-filled with data from ${data.company}</div>
      <small>Found additional details for ${data.firstName} ${data.lastName}</small>
    `;
    document.body.appendChild(notification);

    setTimeout(() => notification.remove(), 3000);
  }
}

// Usage
const enricher = new FormEnrichment("your-api-key");
document.querySelector("#email").addEventListener("blur", (e) => {
  enricher.onEmailChange(e.target.value);
});

Data Sources

Buena.ai aggregates data from multiple premium sources:

Error Responses

Insufficient Credits (402)

{
  "error": true,
  "code": "ENRICHMENT_CREDITS_EXHAUSTED",
  "message": "Insufficient enrichment credits",
  "version": "2.0",
  "timestamp": "2024-01-20T15:30:00Z",
  "details": {
    "remaining": 0,
    "required": 5,
    "upgradeUrl": "https://app.buena.ai/billing"
  }
}

Invalid Lead Data (400)

{
  "error": true,
  "code": "VALIDATION_ERROR",
  "message": "Invalid lead data for enrichment",
  "version": "2.0",
  "timestamp": "2024-01-20T15:30:00Z",
  "details": {
    "errors": [
      {
        "index": 0,
        "message": "At least one identifier (email, LinkedIn URL, or name + company) is required"
      }
    ]
  }
}

Rate Limited (429)

{
  "error": true,
  "code": "RATE_LIMIT_EXCEEDED",
  "message": "Enrichment rate limit exceeded",
  "version": "2.0",
  "timestamp": "2024-01-20T15:30:00Z",
  "retryAfter": 60,
  "details": {
    "limit": "100 enrichments per hour",
    "resetTime": "2024-01-20T16:30:00Z"
  }
}

Best Practices

Next Steps