# Company Enrichment Bulk

## Overview

[Bulks Company Enrichment](https://tomba.io/bulks/company-enrichment) provides comprehensive business intelligence for thousands of companies simultaneously. Gather detailed company information, contact data, and organizational insights to enhance your prospect research and targeting efforts.

### Key Features

- **Company Intelligence**: Gather detailed information about target companies
- **Contact Discovery**: Find key personnel and their contact information
- **Data Enrichment**: Enhance existing company records with additional details
- **Bulk Processing**: Process up to 15,000 companies in one operation
- **Comprehensive Profiles**: Access company size, industry, location, and more
- **Integration Ready**: Export enriched data for CRM integration

### How Company Enrichment Bulk Works

1. **Provide Company List**: Input company domains or names
2. **Select Data Fields**: Choose what information to enrich (contacts, company details, etc.)
3. **Process Enrichment**: Launch the bulk enrichment operation
4. **Review Enhanced Data**: Examine the enriched company profiles
5. **Export Results**: Download comprehensive company intelligence

### Limitations

- Each Bulk is limited to 15,000 domains
- Additional rows will be skipped
- Some special or unexpected characters may be deleted in the file
- Invalid websites won't be imported
- Duplicate URLs won't be imported
- For better results, we use the domain name instead of the company name

## Go SDK Integration

### Installation

```bash
go get github.com/tomba-io/go
```

### Basic Company Enrichment

```go
package main

import (
    "fmt"
    "log"
    "strings"
    "time"

    "github.com/tomba-io/go/tomba"
    "github.com/tomba-io/go/tomba/models"
)

func main() {
    // Initialize Tomba client
    client := tomba.NewClient("YOUR_TOMBA_KEY", "YOUR_TOMBA_SECRET")

    // Create Company Enrichment Bulk
    params := &models.BulkCreateParams{
        Name:    "Enterprise Prospects Q1 2024",
        List:    "stripe.com\nshopify.com\nzoom.us\nslack.com\ndropbox.com\nnotion.so",
        Sources: true, // Include data sources
        Verify:  true, // Verify found emails
    }

    // Create the bulk operation
    response, err := client.CreateBulk(models.BulkTypeCompany, params)
    if err != nil {
        log.Fatal("Error creating company enrichment bulk:", err)
    }

    bulkID := *response.Data.ID
    fmt.Printf("Company Enrichment Bulk created with ID: %d\n", bulkID)

    // Launch the bulk operation
    launchResp, err := client.LaunchBulk(models.BulkTypeCompany, bulkID)
    if err != nil {
        log.Fatal("Error launching bulk:", err)
    }

    fmt.Printf("Bulk launched: %s\n", launchResp.Data.Message)

    // Monitor progress
    fmt.Println("Monitoring enrichment progress...")
    for {
        progress, err := client.GetBulkProgress(models.BulkTypeCompany, bulkID)
        if err != nil {
            log.Printf("Error getting progress: %v", err)
            break
        }

        fmt.Printf("Progress: %d%% (%d companies processed)\n",
            progress.Progress, progress.Processed)

        if progress.Progress >= 100 {
            fmt.Println("Company enrichment completed!")
            break
        }

        time.Sleep(10 * time.Second)
    }

    // Download enriched results
    err = client.SaveBulkResults(models.BulkTypeCompany, bulkID, "./enriched_companies.csv", "full")
    if err != nil {
        log.Printf("Error downloading results: %v", err)
    } else {
        fmt.Println("Enriched company data saved to ./enriched_companies.csv")
    }
}
```

### Advanced Company Enrichment with File Upload

```go
func enrichFromCSV(client *tomba.Tomba, filePath string) error {
    // For large lists, you might want to use CSV upload
    params := &models.BulkCreateParams{
        Name:      "CSV Company Enrichment",
        Sources:   true,
        Verify:    true,
        Delimiter: ",",
        Column:    1, // Domain column in CSV
    }

    // Create with file upload
    response, err := client.CreateBulkWithFile(models.BulkTypeCompany, params, filePath)
    if err != nil {
        return fmt.Errorf("failed to create bulk with file: %w", err)
    }

    bulkID := *response.Data.ID
    fmt.Printf("Company enrichment bulk created from CSV with ID: %d\n", bulkID)

    // Launch and monitor
    _, err = client.LaunchBulk(models.BulkTypeCompany, bulkID)
    if err != nil {
        return fmt.Errorf("failed to launch bulk: %w", err)
    }

    return monitorAndDownload(client, models.BulkTypeCompany, bulkID, "./csv_enriched_results.csv")
}

func monitorAndDownload(client *tomba.Tomba, bulkType models.BulkType, bulkID int64, outputPath string) error {
    // Monitor with timeout
    timeout := time.After(45 * time.Minute)
    ticker := time.NewTicker(30 * time.Second)
    defer ticker.Stop()

    for {
        select {
        case <-timeout:
            return fmt.Errorf("enrichment operation timed out after 45 minutes")

        case <-ticker.C:
            progress, err := client.GetBulkProgress(bulkType, bulkID)
            if err != nil {
                log.Printf("Error checking progress: %v", err)
                continue
            }

            fmt.Printf("Enrichment Progress: %d%% (%d processed)\n",
                progress.Progress, progress.Processed)

            if progress.Progress >= 100 {
                // Download results
                err = client.SaveBulkResults(bulkType, bulkID, outputPath, "full")
                if err != nil {
                    return fmt.Errorf("failed to download results: %w", err)
                }

                fmt.Printf("Results downloaded to: %s\n", outputPath)
                return nil
            }
        }
    }
}
```

### Batch Processing for Large Lists

```go
func batchEnrichCompanies(client *tomba.Tomba, domains []string, batchSize int) error {
    if len(domains) == 0 {
        return fmt.Errorf("no domains provided")
    }

    // Split into batches to stay within limits
    for i := 0; i < len(domains); i += batchSize {
        end := i + batchSize
        if end > len(domains) {
            end = len(domains)
        }

        if end-i > 15000 {
            end = i + 15000 // Respect API limit
        }

        batch := domains[i:end]
        batchNum := (i / batchSize) + 1

        fmt.Printf("Processing batch %d (%d domains)...\n", batchNum, len(batch))

        params := &models.BulkCreateParams{
            Name:    fmt.Sprintf("Company Batch %d - %s", batchNum, time.Now().Format("2006-01-02")),
            List:    strings.Join(batch, "\n"),
            Sources: true,
            Verify:  true,
        }

        response, err := client.CreateBulk(models.BulkTypeCompany, params)
        if err != nil {
            log.Printf("Error creating batch %d: %v", batchNum, err)
            continue
        }

        bulkID := *response.Data.ID

        // Launch batch
        _, err = client.LaunchBulk(models.BulkTypeCompany, bulkID)
        if err != nil {
            log.Printf("Error launching batch %d: %v", batchNum, err)
            continue
        }

        fmt.Printf("Batch %d launched with ID: %d\n", batchNum, bulkID)

        // Small delay between batches
        time.Sleep(5 * time.Second)
    }

    return nil
}
```

### Company Enrichment Management

```go
func manageCompanyBulks(client *tomba.Tomba) {
    // Get all company enrichment bulks
    allBulks, err := client.GetAllCompanyBulks(&models.BulkGetParams{
        Page:      1,
        Limit:     20,
        Direction: "desc",
        Filter:    "all",
    })
    if err != nil {
        log.Printf("Error getting company bulks: %v", err)
        return
    }

    fmt.Printf("Total company enrichment bulks: %d\n", allBulks.Meta.Total)

    // Process each bulk
    for _, bulk := range allBulks.Data {
        fmt.Printf("Bulk: %s (ID: %d)\n", bulk.Name, bulk.BulkID)
        fmt.Printf("  Progress: %d%%, Status: %t, Expired: %t\n",
            bulk.Progress, bulk.Status, bulk.Expired)

        if bulk.TotalEmails != nil {
            fmt.Printf("  Total Emails Found: %d\n", *bulk.TotalEmails)
        }

        // Download completed and unused bulks
        if bulk.Progress >= 100 && !bulk.Used && !bulk.Expired {
            filename := fmt.Sprintf("./company_enrichment_%d.csv", bulk.BulkID)
            err := client.SaveBulkResults(
                models.BulkTypeCompany,
                bulk.BulkID,
                filename,
                "full",
            )
            if err == nil {
                fmt.Printf("  ✓ Downloaded results to %s\n", filename)
            } else {
                fmt.Printf("  ✗ Failed to download: %v\n", err)
            }
        }
    }

    // Clean up old bulks
    cleanupOldBulks(client, allBulks.Data)
}

func cleanupOldBulks(client *tomba.Tomba, bulks []models.BulkItem) {
    cutoffDate := time.Now().AddDate(0, -3, 0) // 3 months ago

    for _, bulk := range bulks {
        // Archive bulks older than 3 months
        if bulk.CreatedAt.Before(cutoffDate) && bulk.Progress >= 100 {
            _, err := client.ArchiveBulk(models.BulkTypeCompany, bulk.BulkID)
            if err == nil {
                fmt.Printf("Archived old bulk: %s (ID: %d)\n", bulk.Name, bulk.BulkID)
            }
        }
    }
}
```

### Input Format Examples

**Text List (recommended):**

```
stripe.com
shopify.com
zoom.us
slack.com
dropbox.com
notion.so
figma.com
```

**CSV File:**

```text
Domain,Company
stripe.com,Stripe Inc
shopify.com,Shopify
zoom.us,Zoom Video Communications
slack.com,Slack Technologies
```

## Best Practices

- **Clean Domain Lists**: Ensure domains are properly formatted without protocols (http/https)
- **Use Domain Names**: Prefer domain names over company names for better accuracy
- **Enable Sources**: Include source information for data validation
- **Verify Emails**: Enable email verification for higher-quality contact data
- **Regular Updates**: Refresh company data periodically as organizations change
- **Data Validation**: Cross-check enriched data with multiple sources
- **Strategic Segmentation**: Organize enriched companies by relevant criteria (size, industry, location)
- **Batch Processing**: For very large lists, process in manageable batches
- **Monitor Progress**: Check progress regularly for large operations
- **Archive Completed**: Archive old bulks to keep dashboard organized

### Common Use Cases

- **Lead Qualification**: Enrich prospect lists with detailed company information
- **Market Research**: Gather intelligence on target markets and competitors
- **Sales Preparation**: Enhance CRM data before sales outreach
- **Partnership Identification**: Find potential partners and strategic relationships
- **Competitive Analysis**: Understand competitive landscape and positioning
- **Account-Based Marketing**: Develop detailed target account profiles
