# Enrichment that behaves like a pipeline stage.

> Enrich up to 10,000 records per async batch, get JSONL or CSV results and a signed webhook, retry safely with idempotency keys, and pay nothing for misses.

Submit up to 10,000 lookups per batch, receive a signed webhook when JSONL or CSV results are ready, and load them into your warehouse. Stable ids, idempotent retries and per-key caps make it safe to schedule.

## Highlights
- **10,000 items per job.** `POST /v1/batch` takes any lookup endpoint and up to 10,000 request bodies. Same price per item, misses free.
- **JSONL or CSV out.** Results land at a `results_url` that stays available for 7 days. Polling `GET /v1/batch/{id}` is free.
- **Signed webhooks.** Every delivery carries a `Dizo-Signature` HMAC header and is retried with backoff for 24 hours.
- **Idempotent retries.** Send an `Idempotency-Key` on every POST; retries within 24 hours are never charged twice.
- **Stable ids and timestamps.** Person records have a stable Dizo id and an `updated_at` timestamp; companies merge on their primary domain.
- **Errors you can branch on.** Stable `error.code` values with `retryable`, `retry_after` and a plain-English `fix`.

## Steps
1. **Extract the input** — Select rows that are new or stale and shape them as request bodies.
2. **Quote and submit** — Dry-run the batch, then submit with `max_credits` and an idempotency key.
3. **Receive and verify** — Verify the webhook signature, then download the JSONL from `results_url`.
4. **Load and merge** — Merge on Dizo person ids and company domains into your warehouse tables, and record when each row was fetched.

## APIs used
| API | Endpoint | Credits | Charged | Reference |
|---|---|---|---|---|
| Batch | `POST /v1/batch` | Same as each item | Per item, same rules | [docs](https://dizo.ai/docs/batch.md) |
| Batch status | `GET /v1/batch/{id}` | Free | Never | [docs](https://dizo.ai/docs/batch-get.md) |
| Webhooks | `POST /v1/webhooks` | Free | Never | [docs](https://dizo.ai/docs/webhooks.md) |
| Domain to company | `GET /v1/companies/{domain}` | 1 credit | Only if found | [docs](https://dizo.ai/docs/domain-to-company.md) |
| Job-change signals | `POST /v1/signals/watch` | 1 credit / change | Per change detected | [docs](https://dizo.ai/docs/signals.md) |


## Where B2B data lands on a data engineer's desk

Go-to-market teams eventually want their account and contact data in the warehouse, joined to product usage, billing and pipeline. That request usually reaches a data engineer as a vague ticket: enrich our accounts with industry and headcount, keep contact titles current, flag bad emails before marketing syncs them. Behind the ticket is a real pipeline problem. You need an external enrichment stage that runs on a schedule, handles hundreds of thousands of rows, fails safely and does not quietly spend a fortune.

Most enrichment products are built for a person clicking in a web app, not for a scheduler. They return one record at a time, rate-limit aggressively, have no idempotency story and bill for every attempt. This page describes how to run Dizo as a proper pipeline stage: batch submission, signed callbacks, JSONL results, incremental refresh and cost control, with the specific endpoints and fields involved.

## What usually goes wrong

The failure modes are predictable. A nightly job retries after a timeout and enriches the same 40,000 rows twice. A webhook handler accepts unsigned requests and anyone can post fake results into your staging table. A full refresh runs every week on a table where 90 percent of rows have not changed. Results arrive with no stable identifier, so merging them means fuzzy matching on company name.

Each of these has a direct fix in the Dizo API. Batches are asynchronous with a single completion event, every POST accepts an `Idempotency-Key`, webhooks are signed with HMAC, records carry stable ids and an `updated_at` timestamp, and lookups that find nothing are free. The rest of this page puts those pieces together.

## The batch contract

[`POST /v1/batch`](/docs/batch) takes an `endpoint`, such as `/v1/email/find` or `/v1/companies/enrich`, and `items`, an array of up to 10,000 request bodies for that endpoint. Optional fields are `webhook_url`, `format` of `jsonl` or `csv`, `dry_run` and `max_credits`. The response returns a batch id, a `queued` status, the item count and a quote with `credits_max`. Each item is priced exactly as the underlying endpoint, and misses remain free.

Track progress with [`GET /v1/batch/{id}`](/docs/batch-get), which is free and returns status, hit count, `results_url` and `credits_used`. Results stay available for 7 days, so download them into your own storage as part of the job rather than treating the URL as durable. For an input of 200,000 rows, the batch count is 20; submit them in parallel or in sequence depending on how you want to spread spend through the day.

## Webhooks you can trust

Register an endpoint once with [`POST /v1/webhooks`](/docs/webhooks) and subscribe to `batch.completed`, plus `billing.cap_warning` and `billing.cap_reached` if you want the pipeline to react to budget events. The signing secret is shown once; store it in your secret manager, and rotate it with `POST /v1/webhooks/{id}/rotate` when needed.

Every delivery includes a `Dizo-Signature` header in the form `t=UNIX_TIME,v1=SIGNATURE`, where the HMAC is SHA-256 over the timestamp, a dot and the raw body, keyed with your secret. Recompute it on the raw bytes before parsing JSON, compare in constant time, and reject old timestamps to stop replays. Deliveries are retried with backoff for 24 hours, so make the handler idempotent on the batch id: receiving `batch.completed` twice should not load the file twice.

## Idempotency, retries and error handling

Send an `Idempotency-Key` header on every POST, derived from something stable such as the job name and the run date plus the batch number. Retries with the same key within 24 hours are never charged twice, which makes it safe for your orchestrator to retry a task that timed out after submitting. Without it, a retried submit is a second batch.

Errors come back with a stable `error.code`, a plain-English `fix`, a `retryable` boolean and, where relevant, `retry_after` in seconds. Branch on the code rather than the HTTP status text. Retry only when `retryable` is true, after the stated delay. Treat `402 monthly_cap_reached` as a stop signal for the whole run, not something to retry, and alert a person. Log the `x-dizo-request-id` header on every call; it is what you pass to the feedback endpoint if a record turns out to be wrong.

## Modelling the results in the warehouse

Person records carry a stable Dizo `id` such as `per_9fK2`; use it as the merge key for people after the first match, rather than a name or an email address that can change. For companies, merge on the primary `domain`, and store the company `id` where the response includes one, such as `com_4hQ1` from domain to company. Keep the raw JSONL lines in a landing table with the batch id and load time, then flatten into typed tables. Fields like `history` and `technologies` are arrays and belong in child tables or semi-structured columns.

Person records have an `updated_at` timestamp showing when Dizo last refreshed them, and email results carry `researched_at` for when the address was researched. Store both, plus your own fetch time for company rows. They let downstream users judge freshness and they drive your refresh logic. The [fields reference](/data/fields) lists every field, its type and an example value, which is a reasonable basis for your schema.

## Incremental refresh instead of full reloads

Dizo refreshes active profiles on a rolling cycle of about 30 days, with frequently requested records sooner. A full re-enrichment of your table every week buys very little. Instead, select only rows that are new since the last run, rows whose source data changed, such as a new email domain, and rows whose stored `updated_at` is older than your freshness threshold, perhaps 60 or 90 days. That is usually a small fraction of the table.

For contacts, change detection can be pushed to Dizo. Add key people to a watchlist with [`POST /v1/signals/watch`](/docs/signals), up to 100,000 per watchlist. Watching is free and each detected job change sends a `signal.job_change` webhook with the old and new role for 1 credit. Write those events to a changes table and you have a slowly changing dimension for employment without polling anyone.

## Cost model for a warehouse backfill and monthly run

Take a hypothetical warehouse with 200,000 account domains. A one-off backfill through domain to company, with 160,000 matches, costs 160,000 credits, since unmatched domains are free. Bought as a single $3,000 purchase at the Growth rate of $0.017, that is 176,470 credits, enough for the backfill with room to spare, so roughly $2,720 of data.

The monthly incremental run then covers 8,000 new domains with 6,400 matches, 15,000 stale rows with 13,000 matches, and 1,000 contacts whose emails bounced, sent to person enrich to find where they went, with 600 matches at 2 credits each. That is 6,400 plus 13,000 plus 1,200, or 20,600 credits a month, about $350 at $0.017. Before each run, submit the batch with `dry_run: true` to confirm the quote, and set `max_credits` on the real submission to the quoted maximum.

- Backfill, 160,000 company matches: 160,000 credits
- Monthly new accounts, 6,400 matches: 6,400 credits
- Monthly stale refresh, 13,000 matches: 13,000 credits
- Monthly bounce re-identification, 600 person matches: 1,200 credits

## Keys, caps and when to ask for bulk delivery

Give the pipeline its own key with `data:read` only, an `allowed_endpoints` list limited to batch and the lookup paths it uses, and daily and monthly credit caps sized to the expected run plus a margin. Call `GET /v1/me` at the start of each run to confirm scopes and remaining budget, and abort early if the budget cannot cover the quote. Keep billing locked so the pipeline key can never top up or change refills.

If your volumes go well beyond what scheduled batches are good for, Dizo also offers bulk delivery under enterprise terms: full or filtered datasets as CSV, Parquet or JSONL delivered to S3, GCS, Azure Blob, Snowflake or SFTP, refreshed monthly or weekly. That conversation goes through sales@dizo.ai. For everything else, build against `dz_test_` keys, which return synthetic data for free, and [sign up](/signup) for live access. The [data warehouse enrichment](/use-cases/data-warehouse-enrichment) use case has a worked pipeline.

## FAQ

### How many records can one batch hold?
Up to 10,000 items, all for the same lookup endpoint. For larger tables, split the input into several batches and submit them in parallel or in sequence.

### How long are batch results available?
Results stay available for 7 days at the `results_url`. Download them into your own storage as part of the job.

### How do I verify a Dizo webhook?
Compute HMAC-SHA256 with your signing secret over the timestamp, a dot and the raw request body, and compare it with the `v1` value in the `Dizo-Signature` header. Reject stale timestamps to prevent replays.

### What happens if my orchestrator retries a submission?
If you send the same `Idempotency-Key`, retries within 24 hours are never charged twice. Without a key, a retry creates a second batch.

### Do I pay for rows that do not match?
No. Batch items follow the same charging rule as the underlying endpoint, so misses are free. A domain that does not match costs nothing, and neither does an email lookup that finds no valid address.

### Can I get the data delivered to my warehouse directly?
Bulk delivery of full or filtered datasets to S3, GCS, Azure Blob, Snowflake or SFTP is available under enterprise terms. Contact sales@dizo.ai.
