# Domain Search

List the email addresses found for a company domain (one row per email). Find the people and email addresses Tomba knows at a company, for account-based prospecting.

**Credits:** 1 search credit per 10 emails requested, when emails are found. Lookups that find nothing cost nothing. See [Pricing and limits](../pricing-and-limits).

## Inputs and options

Input: `domain` (Company domain)

| Option              | Type    | Default | Description                                                                               |
| ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------- |
| `emails_per_domain` | INT     | `10`    | Emails per domain. One of: 1, 5, 10, 20, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500. |
| `enrich_mobile`     | BOOLEAN | `false` | Also look up mobile phones (+5 credits per phone found).                                  |
| `department`        | STRING  | `''`    | Departments (comma separated).                                                            |
| `country`           | STRING  | `''`    | Country (ISO-2).                                                                          |
| `email_type`        | STRING  | `''`    | Email type. One of: '', 'all', 'personal', 'generic'.                                     |

## Try one value

```sql
CALL TOMBA.core.domain_search('acme.com', 10);
```

The call returns the result as a `VARIANT` (example values, shortened):

```json
{
    "status": "found",
    "credits": 1,
    "results": [
        {
            "EMAIL": "jane.doe@acme.com",
            "FULL_NAME": "Jane Doe",
            "POSITION": "Head of Sales",
            "DEPARTMENT": "sales",
            "SENIORITY": "senior"
        },
        {
            "EMAIL": "john@acme.com",
            "FULL_NAME": "John Roe",
            "POSITION": "CTO",
            "DEPARTMENT": "engineering",
            "SENIORITY": "executive"
        }
    ]
}
```

`status` is `found`, `not_found`, `invalid` or `error`; `results` holds the output columns and `data` the complete
Tomba record.

## Run it over a table

Create a small table to try it (or use one of yours, after [granting the app access](../installation#3-let-the-app-read-your-tables)):

```sql
CREATE OR REPLACE TABLE my_db.public.accounts (WEBSITE STRING);
INSERT INTO my_db.public.accounts VALUES
    ('acme.com'),
    ('globex.com');
GRANT SELECT ON TABLE my_db.public.accounts TO APPLICATION TOMBA;
```

Run the tool, then read the results:

```sql
CALL TOMBA.core.search_domains('MY_DB.PUBLIC.ACCOUNTS', 'WEBSITE', 'ACCOUNTS_DOMAIN_SEARCH', 100);

SELECT INPUT_DOMAIN, EMAIL, FULL_NAME, POSITION, DEPARTMENT, SENIORITY, VERIFICATION_STATUS
  FROM TOMBA.results.ACCOUNTS_DOMAIN_SEARCH
 WHERE lookup_status = 'found';
```

Signature: `search_domains(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000, emails_per_domain INT DEFAULT 10)`

### Other inputs with `run_tool`

Only sales people in Germany, 20 per domain:

```sql
CALL TOMBA.core.run_tool('domain_search', 'MY_DB.PUBLIC.ACCOUNTS', {'domain': 'WEBSITE'},
                         'ACCOUNTS_DOMAIN_SEARCH_2', 100, {'emails_per_domain': 20, 'department': 'sales', 'country': 'DE'});
```

<Callout type="tip">
    Start with a small `max_rows` (like 100) to check the match rate on your
    data, then run the whole table, in the [background](../background-runs) if
    it is large.
</Callout>

## Output columns

Each row starts with `INPUT_<name>` columns (your values, unchanged) and then has:

`EMAIL`, `FIRST_NAME`, `LAST_NAME`, `FULL_NAME`, `POSITION`, `DEPARTMENT`, `SENIORITY`, `EMAIL_TYPE`, `SCORE`, `VERIFICATION_STATUS`, `COUNTRY`, `LINKEDIN`, `TWITTER`, `PHONE_NUMBER`, `ORGANIZATION`, `INDUSTRIES`, `COMPANY_SIZE`, `COMPANY_TYPE`, `ORGANIZATION_COUNTRY`, followed by the [common columns](../reference/output-columns)
(`LOOKUP_STATUS`, `CREDITS`, `DATA`, `SOURCE`, …).

## Tips

- The output has **one row per email**, so a domain can produce many rows.
- Credits: 1 per 10 emails requested (`emails_per_domain` 20 = 2 credits per domain with results).
- Filter by `department`, `country` or `email_type` (`personal` or `generic`) with `run_tool` options.

## Related

- [Email Finder](./email-finder)
- [Company Enrichment](./company-enrichment)
- [Similar Domains](./similar-domains)
