# Airtable + Dizo

> Enrich Airtable records with a Run a script automation that calls Dizo with fetch() and writes the email and title back to the row.

Type: REST recipe — base URL `https://api.dizo.ai/v1`. No native app needed.

## Steps
1. Store your key as an Airtable secret (Builder Hub) named `DIZO_API_KEY`, then add it to the automation under **Secrets → Add existing secret**.
2. Create an automation with a trigger such as **When record matches conditions** (Email is not empty, Title is empty).
3. Add a **Run a script** action and an input variable `recordId` mapped to the trigger record's ID.
4. Paste the script below. It calls Dizo, then updates the same record with `updateRecordAsync`.
5. Test the action on one record before turning the automation on.

## Where to go
In Automations, add **Run a script** and call `fetch()` with an `Authorization: Bearer` header.

Open the Airtable scripting fetch docs: https://airtable.com/developers/scripting/api/fetch

## Run a script action
```
const { recordId } = input.config();
const key = input.secret('DIZO_API_KEY');
const table = base.getTable('Leads');
const record = await table.selectRecordAsync(recordId);
if (!record) throw new Error('Record not found');

const res = await fetch('https://api.dizo.ai/v1/people/enrich', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${key}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': recordId,
  },
  body: JSON.stringify({
    email: record.getCellValueAsString('Email'),
    max_credits: 2,
  }),
});

if (res.status === 404) {
  output.set('status', 'not_found');   // not charged
} else if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${error.code}: ${error.fix}`);
} else {
  const { person } = await res.json();
  await table.updateRecordAsync(recordId, {
    'Title': person.title,
    'Seniority': person.seniority,
  });
  output.set('status', 'enriched');
}
```

## Notes
- Airtable caps how many `fetch()` calls one script run can make. For a few hundred rows at once, send them to `POST /v1/batch` instead of looping.
- Scripts that reference a secret can only be edited by people with access to that secret, and secret values are redacted from console output.

## Related API docs
- [/docs/people-enrich](https://dizo.ai/docs/people-enrich.md)
- [/docs/batch](https://dizo.ai/docs/batch.md)


## What Airtable is, and where Dizo fits

Airtable is a database with a spreadsheet's interface. Many GTM teams run their lead lists, event attendee tables, partner trackers and account plans in it because anyone can add a field or a view without asking engineering. Automations add behaviour: a trigger such as a record matching conditions, a form submission or a schedule, followed by actions.

One of those actions is **Run a script**. It runs JavaScript in the background of the base, can call outside services with `fetch()`, reads inputs through `input.config()`, reads stored secrets with `input.secret()`, and passes values to later actions with `output.set()`. That is the whole integration. There is no Dizo extension or listing in Airtable; a short script calls `https://api.dizo.ai/v1` and writes the result back to the record.

## Why enrich inside the base

Airtable tables fill up with half-records. An event export has names and companies but no emails. A form captures an email and nothing about the person. A partner sends a list of domains. Copying those rows into another tool, enriching them and pasting them back is slow and error-prone, and it leaves you with two versions of the truth.

Running Dizo inside an automation keeps the base as the single source. A row that matches your conditions is enriched once, in place, the moment it qualifies. And because Dizo charges only for what it finds, the cost follows the useful rows: [person enrich](/docs/people-enrich) is 2 credits if the person is matched, an email lookup is 1 credit only if found, and a row that matches nobody costs nothing.

## What you can do with it

Swap the endpoint and the fields the script reads and writes, and the same automation handles a range of table types:

- Add title, seniority and department to every lead that has an email but no title.
- Find a verified work email for event attendees from first name, last name and company domain.
- Turn a partner's list of domains into company rows with headcount, industry, revenue band and HQ.
- Re-run email find on rows whose address bounced, using the contact's current company domain, at 1 credit only if a valid address comes back, and flag the rest for suppression.
- Add a mobile number only to rows a rep marks as priority, using a checkbox in the trigger condition.
- Identify the person behind a bare email in a support or inbound table with `POST /v1/people/by-email`.
- Push opted-out contacts to Dizo's suppression list so they never come back in future searches.

## Setting up the automation

Start with the secret. Airtable stores API keys as secrets, managed in Builder Hub, and an automation can read one by name with `input.secret('DIZO_API_KEY')`. Create the secret with your `dz_live_...` key, then in the automation's script settings choose **Secrets → Add existing secret** and add it. Airtable redacts secret values from console output, and a script that references a secret can only be edited by people with access to that secret.

Create the trigger. **When record matches conditions** is the natural choice: for example, Email is not empty and Title is empty. That condition doubles as a guard. Once the script fills Title, the record no longer matches, so it will not be enriched again by accident.

Add a **Run a script** action. In the sidebar, add an input variable named `recordId` and map it to the trigger record's ID. Paste the script from the recipe above and change the table and field names to yours. The script loads the record with `selectRecordAsync`, posts the email to Dizo with `max_credits: 2`, and on success writes title and seniority back with `updateRecordAsync`. A `404` sets an output of `not_found` and writes nothing. Any other error throws with Dizo's `error.code` and `error.fix`, so the automation's run history shows exactly what went wrong.

Use **Test** on one record before turning the automation on. [Sign up](/signup) for a live key and 250 free credits, with no card. A `dz_test_` key returns synthetic data and never spends credits, which is enough to build the automation and check your field mapping.

## Working within Airtable's script limits

Airtable sets limits on automation scripts, including a cap on how many `fetch()` requests one run can make, a per-request fetch timeout and an overall script timeout. Check Airtable's Run a script article for the current numbers. The practical effect is that one automation run should handle one record, or a small handful, not a whole table.

For a one-time backfill of hundreds or thousands of rows, do not loop inside a single script. Send them to [batch](/docs/batch) instead: up to 10,000 lookups in one async job, the same per-item price, misses still free. Collect the record IDs and emails, post one batch request, and store the returned batch id in a field. A scheduled automation can then poll `GET /v1/batch/{id}`, which is free, and when the status is completed, fetch the results and write them back in groups. Keep each write within Airtable's mutation limits.

Before a backfill, size it. Send the same rows to the batch endpoint with `"dry_run": true` first, or run a free `POST /v1/count` on a matching segment, and you will know the maximum cost before a single credit is spent. Remember that the real charge is usually lower, because misses are free.

## Controlling spend

The trigger condition is your first control: only rows that need data qualify. The second is `max_credits` on every request; the recipe sets 2, which is exactly the cost of a matched person with no extras. The third is a dedicated key for the base, created through [API keys](/docs/keys) with `data:read` scope, a monthly credit cap and an allow-list of only the endpoints the script calls. The fourth is the account's monthly USD cap through [spend limits](/docs/billing-limits), which auto-refill never exceeds.

A hypothetical month for an events team: 2,000 attendees, 1,500 with name and company domain, 1,100 emails found. That is 1,100 credits, since misses are free: $27.50 at the $0.025 pay-as-you-go rate. If 50 of those addresses bounce later and a re-run of email find turns up 30 new ones, that adds 30 credits. Adding mobile numbers for the 60 rows marked priority, with 40 found, adds 400 credits. If you buy credits in a $500 purchase, the Builder rate of $0.021 applies to everything.

## Example automations

**Event follow-up table.** Trigger on records where Work Email is empty and Company Domain is not. The script calls email find with first name, last name and domain, at 1 credit only if found, and writes the address plus its `confidence` score into two fields. Every address that comes back has `status: "verified"`, so a view filtered to filled emails, sorted by confidence, becomes your send list.

**Account table from domains.** Trigger on records where Domain is not empty and Employees is empty. The script calls `POST /v1/companies/enrich` with `max_credits: 1` and fills headcount, industry, revenue band and HQ city. A second automation, triggered when Employees falls within your target range, sets a Tier field so reps see priority accounts first.

**Opt-out sync.** When a record's Unsubscribed checkbox is ticked, the script posts that email to `POST /v1/suppression`, which is free. Dizo will never return that contact to your account again, in any tool.

## Troubleshooting

If the script fails with an authentication error, check that the secret was added to this automation, not just created in Builder Hub, and that the name passed to `input.secret()` matches exactly. A `402` means a cap was reached; the record stays unenriched and nothing further is charged. Decide whether to raise the cap rather than re-running.

If the same row seems to be enriched twice, the trigger condition is probably not cleared by the fields the script writes. Make the condition depend on a field the script fills. The recipe also sends an `Idempotency-Key` equal to the record ID, so a repeat within 24 hours is never charged twice. If a field write fails, check the field type: a single-select field needs a value that exists among its options.

## Security practices

Never paste the key into the script body or an input variable; anyone with access to the script could read it. Use an Airtable secret, and keep the list of people who can use that secret short. Use separate Dizo keys for different bases so revoking one does not break the rest.

Give the key `data:read` only. It should never hold `billing:write` or `keys:write`. For how Dizo handles opt-outs, verification and data requests, see the [trust page](/trust).

## FAQ

### Is there a Dizo extension for Airtable?
No. There is no native Dizo app or listing. You call the Dizo REST API from a Run a script automation action using `fetch()`.

### Where should I store the Dizo key?
In an Airtable secret, read with `input.secret('DIZO_API_KEY')` inside the automation. Secrets are redacted from console output, and scripts that use them can only be edited by people with access to the secret.

### Can I enrich a whole table at once?
Not inside one script run, because Airtable limits fetch requests per run. For a backfill, send the rows to Dizo's batch endpoint as one async job and write results back from a scheduled automation.

### What if Dizo finds nobody for a row?
The API returns `404 not_found` and charges nothing. The recipe script records `not_found` as an output and leaves the row unchanged.

### How do I stop a row being enriched twice?
Make the trigger condition depend on a field the script fills, such as Title is empty. Also send an `Idempotency-Key` with the record ID so a repeat within 24 hours is not charged twice.

### Does this work in the Scripting extension too?
The pattern is similar, but Airtable documents secrets as available to automations only. Use the Run a script automation action so the key stays in a secret.
