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

# Table enrichment pipeline

> Create a table, add rows, attach an enrichment, and run it across all rows with a few API calls.

Tables let you store structured data in Databar and run enrichments across all rows without managing individual API calls. This is the best approach when you want persistent, viewable results that you can also access in the Databar UI.

## What you will do

1. Create a table with columns
2. Insert rows
3. Find and attach an enrichment
4. Run the enrichment on all rows
5. View results in the API or UI

## Prerequisites

* A Databar API key ([get one here](https://databar.ai))
* A dataset (names, emails, domains, etc.)

## Step 1: Create a table

```bash theme={null}
curl -X POST "https://api.databar.ai/v1/table/create" \
  -H "x-apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Lead Enrichment",
    "columns": ["name", "company", "domain"]
  }'
```

Save the `uuid` from the response. You will use it in every subsequent call.

## Step 2: Insert rows

```bash theme={null}
curl -X POST "https://api.databar.ai/v1/table/TABLE_UUID/rows" \
  -H "x-apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rows": [
      {"fields": {"name": "Sarah Chen", "company": "Stripe", "domain": "stripe.com"}},
      {"fields": {"name": "James Lee", "company": "Notion", "domain": "notion.so"}},
      {"fields": {"name": "Maria Garcia", "company": "Figma", "domain": "figma.com"}}
    ]
  }'
```

You can insert up to 100 rows per request.

## Step 3: Find and attach an enrichment

First, find the enrichment you want:

```bash theme={null}
curl "https://api.databar.ai/v1/enrichments/?q=company%20data" \
  -H "x-apikey: YOUR_API_KEY"
```

Then attach it to the table with a column mapping that tells Databar which columns to use as input:

```bash theme={null}
curl -X POST "https://api.databar.ai/v1/table/TABLE_UUID/add-enrichment" \
  -H "x-apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enrichment": ENRICHMENT_ID,
    "mapping": {
      "domain": {
        "value": "domain",
        "type": "mapping"
      }
    }
  }'
```

Each mapping key is an enrichment parameter slug. Set `type` to `"mapping"` to pull the value from a table column (use the column name or UUID as the `value`), or `"simple"` to pass a static value to every row. Save the returned `id` - this is the table-enrichment ID you will use to run it.

## Step 4: Run the enrichment

```bash theme={null}
curl -X POST "https://api.databar.ai/v1/table/TABLE_UUID/run-enrichment/TABLE_ENRICHMENT_ID" \
  -H "x-apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

This runs the enrichment on all rows. Use `"run_strategy": "run_empty"` to only process rows that have not been enriched yet.

## Step 5: View results

Fetch the enriched rows:

```bash theme={null}
curl "https://api.databar.ai/v1/table/TABLE_UUID/rows" \
  -H "x-apikey: YOUR_API_KEY"
```

Or open the table directly in the Databar UI at `https://databar.ai/table/TABLE_UUID`.

## With the Python SDK

```python theme={null}
from databar import DatabarClient

client = DatabarClient()

# Create table and add rows
table = client.create_table(name="Lead Enrichment", columns=["name", "company", "domain"])

client.create_rows(table.uuid, [
    {"name": "Sarah Chen", "company": "Stripe", "domain": "stripe.com"},
    {"name": "James Lee", "company": "Notion", "domain": "notion.so"},
    {"name": "Maria Garcia", "company": "Figma", "domain": "figma.com"},
])

# Attach and run enrichment
te = client.add_enrichment(table.uuid, ENRICHMENT_ID, mapping={
    "domain": {"value": "domain", "type": "mapping"}
})
client.run_table_enrichment(table.uuid, te.id)

# Fetch results
rows = client.get_table_rows(table.uuid)
for row in rows:
    print(row)
```

## Next steps

<CardGroup cols={2}>
  <Card title="Enrich leads" icon="magnifying-glass" href="/guides/enrich-leads">
    Run a quick headless enrichment without creating a table.
  </Card>

  <Card title="Waterfall email finder" icon="water" href="/guides/waterfall-email-finder">
    Maximize email coverage by trying multiple providers.
  </Card>
</CardGroup>
