# Procedures

Every procedure is in the app's `core` schema, returns a `VARIANT`, and is called as
`CALL TOMBA.core.<procedure>(...)`. Pass objects (not JSON strings) for `VARIANT` arguments, for example
`{'domain': 'WEBSITE'}`.

## Tools on a table

| Procedure                                                                                                                                                    | What it does                                                     | Role         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- | ------------ |
| `find_emails(input_table STRING, domain_column STRING, first_name_column STRING, last_name_column STRING, output_table STRING, max_rows INT DEFAULT 100000)` | [Email Finder over a table](../tools/email-finder)               | `app_public` |
| `verify_emails(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [Email Verifier over a table](../tools/email-verifier)           | `app_public` |
| `search_domains(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000, emails_per_domain INT DEFAULT 10)`               | [Domain Search over a table](../tools/domain-search)             | `app_public` |
| `enrich_emails(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [Email Enrichment over a table](../tools/email-enrichment)       | `app_public` |
| `enrich_people(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [Person Enrichment over a table](../tools/person-enrichment)     | `app_public` |
| `enrich_companies(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                               | [Company Enrichment over a table](../tools/company-enrichment)   | `app_public` |
| `enrich_combined(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                 | [Combined Enrichment over a table](../tools/combined-enrichment) | `app_public` |
| `find_emails_from_linkedin(input_table STRING, url_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                         | [LinkedIn Finder over a table](../tools/linkedin-finder)         | `app_public` |
| `find_authors(input_table STRING, url_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                      | [Author Finder over a table](../tools/author-finder)             | `app_public` |
| `find_phones(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                     | [Phone Finder over a table](../tools/phone-finder)               | `app_public` |
| `validate_phones(input_table STRING, phone_column STRING, output_table STRING, max_rows INT DEFAULT 100000, country_code_column STRING DEFAULT '')`          | [Phone Validator over a table](../tools/phone-validator)         | `app_public` |
| `find_similar_domains(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                           | [Similar Domains over a table](../tools/similar-domains)         | `app_public` |

## Tools on one value

| Procedure                                                          | What it does                                                      | Role         |
| ------------------------------------------------------------------ | ----------------------------------------------------------------- | ------------ |
| `email_finder(domain STRING, first_name STRING, last_name STRING)` | [Email Finder for one value](../tools/email-finder)               | `app_public` |
| `email_verifier(email STRING)`                                     | [Email Verifier for one value](../tools/email-verifier)           | `app_public` |
| `domain_search(domain STRING, emails_per_domain INT DEFAULT 10)`   | [Domain Search for one value](../tools/domain-search)             | `app_public` |
| `email_enrichment(email STRING)`                                   | [Email Enrichment for one value](../tools/email-enrichment)       | `app_public` |
| `person_enrichment(email STRING)`                                  | [Person Enrichment for one value](../tools/person-enrichment)     | `app_public` |
| `company_enrichment(domain STRING)`                                | [Company Enrichment for one value](../tools/company-enrichment)   | `app_public` |
| `combined_enrichment(email STRING)`                                | [Combined Enrichment for one value](../tools/combined-enrichment) | `app_public` |
| `linkedin_finder(url STRING)`                                      | [LinkedIn Finder for one value](../tools/linkedin-finder)         | `app_public` |
| `author_finder(url STRING)`                                        | [Author Finder for one value](../tools/author-finder)             | `app_public` |
| `phone_finder(email STRING)`                                       | [Phone Finder for one value](../tools/phone-finder)               | `app_public` |
| `phone_validator(phone STRING, country_code STRING DEFAULT '')`    | [Phone Validator for one value](../tools/phone-validator)         | `app_public` |
| `similar_finder(domain STRING)`                                    | [Similar Domains for one value](../tools/similar-domains)         | `app_public` |

## Any tool

| Procedure                                                                                                        | What it does                                                                                                    | Role         |
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------ |
| `run_tool(tool STRING, input_table STRING, columns VARIANT, output_table STRING, max_rows INT, options VARIANT)` | [Any tool over a table, with a column mapping and options](../enrich-a-table#other-input-combinations-run_tool) | `app_public` |
| `lookup(tool STRING, params VARIANT)`                                                                            | One lookup with any tool and inputs                                                                             | `app_public` |
| `search_companies(filters VARIANT, output_table STRING, max_results INT DEFAULT 500)`                            | [Companies matching filters, into a table](../tools/companies-search)                                           | `app_public` |

## Background runs and resume

| Procedure                                                                                                              | What it does                                                                  | Role         |
| ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------ |
| `run_tool_async(tool STRING, input_table STRING, columns VARIANT, output_table STRING, max_rows INT, options VARIANT)` | [`run_tool` in the background; returns the run id](../background-runs)        | `app_public` |
| `search_companies_async(filters VARIANT, output_table STRING, max_results INT DEFAULT 500)`                            | [`search_companies` in the background](../background-runs)                    | `app_public` |
| `cancel_run(run_id STRING)`                                                                                            | [Stop a running or queued run](../background-runs#cancel)                     | `app_public` |
| `resume_run(run_id STRING)`                                                                                            | [Continue a stopped run](../resume-and-auto-resume)                           | `app_public` |
| `set_auto_resume(run_id STRING, enabled BOOLEAN)`                                                                      | [Turn auto-resume on or off for a run](../resume-and-auto-resume#auto-resume) | `app_public` |
| `resume_pending()`                                                                                                     | Resume every run marked for auto-resume now (the app runs it daily)           | `app_public` |
| `process_jobs()`                                                                                                       | Start queued background runs (the app runs it automatically)                  | `app_public` |

## Schedules

| Procedure                                                                                                                           | What it does                                             | Role         |
| ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ------------ |
| `create_schedule(name STRING, tool STRING, input_table STRING, columns VARIANT, output_table STRING, cron STRING, options VARIANT)` | [Keep a table enriched on a CRON schedule](../schedules) | `app_admin`  |
| `list_schedules()`                                                                                                                  | Schedules and their last run                             | `app_public` |
| `pause_schedule(name STRING)`                                                                                                       | Pause a schedule                                         | `app_admin`  |
| `resume_schedule(name STRING)`                                                                                                      | Restart a paused schedule                                | `app_admin`  |
| `run_schedule(name STRING)`                                                                                                         | Run a schedule now                                       | `app_public` |
| `drop_schedule(name STRING)`                                                                                                        | Delete a schedule (its table stays)                      | `app_admin`  |

## Utilities

| Procedure                                | What it does                                                                      | Role         |
| ---------------------------------------- | --------------------------------------------------------------------------------- | ------------ |
| `status()`                               | App version, connection approval, trial, daily limit                              | `app_public` |
| `list_tools()`                           | Every tool with its inputs, options, credits and columns                          | `app_public` |
| `pricing()`                              | [Price per credit and credits per tool](../pricing-and-limits)                    | `app_public` |
| `usage_summary(days INT DEFAULT 30)`     | [Runs, credits and charges per day and tool](../results-and-history#usage-by-day) | `app_public` |
| `get_settings()`                         | [Current settings](./settings)                                                    | `app_public` |
| `set_setting(name STRING, value STRING)` | [Change a setting](./settings)                                                    | `app_admin`  |
| `clear_cache(tool STRING DEFAULT '')`    | [Forget cached results for a tool ('' for all)](../cache-and-budgets)             | `app_admin`  |
| `drop_result(output_table STRING)`       | [Drop a result table](../results-and-history)                                     | `app_public` |
| `reset_credentials()`                    | Make the app reconnect to Tomba on its next lookup                                | `app_admin`  |

Views: `TOMBA.core.runs` (every run) and `TOMBA.core.usage_by_day`. See [Results and history](../results-and-history).
