# Build the whole integration before you spend a credit.

> Keys starting dz_test_ return synthetic data and never spend credits. Build, test and run CI against the real Dizo API shapes at no cost.

A `dz_test_` key hits the same endpoints with the same request and response shapes, but returns synthetic records and costs nothing. Swap in a live key when you are ready.

## Highlights
- **Always free.** Test keys never spend credits, however many calls you make.
- **Synthetic data.** Records are generated sandbox data, safe for demos, fixtures and logs.
- **Same API surface.** Same base URL, same endpoints, same JSON. Only the key prefix changes.
- **Works over MCP.** Connect an MCP client with a test key to try agent prompts without a budget.
- **Always free.** Test keys never spend credits, and the playground needs no key at all.
- **Matches the playground.** The browser playground shows the same sandbox data as test keys.

## Steps
1. **Get a test key** — Use a key that starts with `dz_test_`.
2. **Build against it** — Call any endpoint at `https://api.dizo.ai/v1` exactly as you would in production.
3. **Wire it into CI** — Run integration tests on every commit at zero cost.
4. **Swap to live** — Change the key to `dz_live_` from config. No code changes.

## APIs used
| API | Endpoint | Credits | Charged | Reference |
|---|---|---|---|---|
| Natural-language search | `POST /v1/search` | 1 credit / 25 results | Per result returned | [docs](https://dizo.ai/docs/search.md) |
| Email finder | `POST /v1/email/find` | 1 credit | Only if found | [docs](https://dizo.ai/docs/email-find.md) |
| Key info | `GET /v1/me` | Free | Never | [docs](https://dizo.ai/docs/me.md) |
| Batch | `POST /v1/batch` | Same as each item | Per item, same rules | [docs](https://dizo.ai/docs/batch.md) |


## The cost of learning an API with real money

Every data API has the same awkward start. You want to know what the response looks like, how errors come back and how pagination works, but every call you make to find out costs something. Developers end up writing their first integration against a handful of expensive real lookups, then mocking the rest by hand, then discovering in production that the mock was wrong about a field name.

Dizo test keys remove that trade-off. A key that starts with `dz_test_` calls the same endpoints at the same base URL, `https://api.dizo.ai/v1`, and gets back responses in the same shape. The records are synthetic, and the key never spends credits. You can build the whole integration, run it in a loop, break it on purpose and run it again in CI on every commit, all for nothing.

[Sign up](/signup) to get a live key. Build against the sandbox first, so your integration is ready before you spend any credits.

## What a test key does and does not do

A test key is a normal key with one difference: it reads from a sandbox instead of the live dataset, and nothing it does is billed. Requests go to the same paths, accept the same parameters and return the same fields, such as `person_id`, `status`, `confidence` and `credits_used`. That means your parser, your ledger code and your error handling can be written once and pointed at either environment, with the key prefix as the only switch.

What a test key does not do is return real people. Names, companies, emails and phone numbers in the sandbox are generated. Do not email them, do not call them and do not load them into a CRM as prospects. They exist so that your parser, your retry logic and your agent prompts have something realistic to work on.

Treat the two prefixes as two environments. `dz_test_` lives in development and CI. `dz_live_` lives in production config. Keeping them in separate secret stores prevents the classic mistake of a test suite quietly running against live data.

## Building an integration end to end

A practical order of work: start with `GET /v1/me` to confirm the key and see its scopes and limits. Then make one call to each endpoint you plan to use. For an outbound flow that is usually `POST /v1/search` with a plain-English `query`, then `POST /v1/email/find` with a `person_id` from the search results, then `POST /v1/phone/find` for the contacts worth a call. Save the responses as fixtures.

Next, exercise the failure paths. A miss on the email finder comes back as `404 not_found` and would cost nothing on a live key. Errors carry a stable `error.code` and a plain-English `error.fix`, plus `error.retryable` and `error.retry_after`. Write your branching logic against those fields now, while each attempt is free.

Finally, run the asynchronous pieces. Submit a small `POST /v1/batch` job with a `webhook_url`, poll `GET /v1/batch/{id}` until it completes and parse the results file. If you use lists or monitors, create one and handle the `list.completed` or `monitor.new_results` webhook. By the end you have covered every code path without a single billed call.

## A first-afternoon checklist

If you have a few hours and a test key, this order gets you from nothing to a tested integration. Each item is free in the sandbox, and each one maps to a code path you will need in production anyway.

Work through the list in order and save every response you get as a fixture. By the end you have a realistic set of sample payloads, a branch for every error you expect, and a CI job that proves it all still works tomorrow.

- Call `GET /v1/me` and log the scopes, allow-list and budget it reports.
- Run one plain-English `POST /v1/search` and inspect the `interpreted` filters.
- Pass a `person_id` from that search to `POST /v1/email/find`.
- Force a miss and handle `404 not_found` as a normal outcome, not a crash.
- Send the same POST twice with one `Idempotency-Key` and confirm your code treats it as one operation.
- Submit a small batch with a `webhook_url` and verify the `Dizo-Signature` header in your handler.
- Read `x-dizo-credits-used` and `x-dizo-credits-remaining` on every response and write them to your logs.

## Test keys in CI

Because test keys are always free, they fit in continuous integration. Store a `dz_test_` key as a CI secret and run a small suite on every push: one search, one email find, one enrich, one count, one batch. Assert on field names and types rather than on specific values, since synthetic records are for shape, not for business logic.

This catches the failures that hurt most in production: a renamed field in your own code, a broken retry, a serializer that mangles E.164 phone numbers, a webhook handler that rejects valid signatures. Running those checks against a mock you wrote yourself only proves the mock agrees with your code. Running them against the real API, with sandbox data, proves your code agrees with Dizo.

Send an `Idempotency-Key` header on POSTs in your tests too. It costs nothing to practise, and it means the habit is already in place when the same code starts spending real credits.

## Testing agents and MCP tools

Agents are harder to test than scripts, because you cannot predict exactly which tools they will call. That is where a free key earns its keep. Connect an MCP client to `https://mcp.dizo.ai/mcp` with `Authorization: Bearer dz_test_...` and try your real prompts: find heads of RevOps at fintech companies, get their emails, skip any phone with a DNC flag. Watch which tools the agent picks and in what order.

You will usually find something to fix. The agent may call phone finder when you only wanted email, skip the free `dizo_count` step, or forget to set `max_credits`. Tighten the system prompt, narrow the key's `allowed_endpoints` and run the conversation again. Each iteration is free. The [MCP server](/mcp) page lists every tool and its live credit cost, which the agent also sees in each tool description.

Clients such as [Claude Code](/integrations/claude-code) accept the key in a header at install time, so switching between test and live is one configuration change.

## Test keys, dry runs and the playground

Three Dizo tools sound similar and do different jobs. A test key runs the full call against synthetic data and spends nothing. A dry run, `"dry_run": true` on a live key, prices a real call exactly but returns no data and spends nothing. The [API playground](/features/api-playground) lets you try endpoints in a browser against the same sandbox data as test keys.

Use them in that order. Explore in the playground to understand what each endpoint returns. Build and test the integration with a test key. Then, once you are live, add dry runs before any large job to see the exact credits a real search, list or batch would use. A test key tells you whether your code works; a dry run tells you what the real job will cost.

## Going live

When you sign up you get 250 free credits with no card. Create a live key for the job, scope it with `data:read` and a short allow-list, set daily and monthly caps, and put the secret in your production secret store. Change the key in config. No code changes should be needed, because the endpoints and shapes are the same.

Before turning the full job on, run it once with `dry_run` to confirm the expected spend, then run a small real slice. Compare credits used with your forecast. A team planning 1,000 email lookups a month at a 70% hit rate should expect about 700 credits, which is $17.50 at the $0.025 pay-as-you-go rate, since misses are free. Check [pricing](/pricing) for the volume tiers.

## Common mistakes

The fix for nearly all of these is to treat the sandbox as a contract test environment: check shapes, codes and flows there, and leave judgements about data quality to small, real, capped runs once you are live.

- Asserting on specific synthetic names or emails in tests instead of on field names and types.
- Using sandbox records as real prospects. They are not real people.
- Keeping test and live keys in the same environment variable across environments.
- Skipping failure-path tests because the happy path worked first time.
- Assuming a dry run and a test key are the same. One prices, the other simulates.

## FAQ

### Are test keys really free?
Yes. Keys that start with `dz_test_` return synthetic data and never spend credits, however many calls you make.

### Is the test data real?
No. Sandbox records are synthetic. Use them to build and test your code, never as real prospects.

### Do I need an account to use the sandbox?
No. [Sign up](/signup) for a live key; the playground and `dz_test_` keys show sandbox data now.

### Do test keys work with the MCP server?
Yes. Pass a test key as `Authorization: Bearer dz_test_...` when you connect to `https://mcp.dizo.ai/mcp` and try your agent prompts at no cost.

### What changes when I switch to a live key?
Only the key. Endpoints, parameters and response shapes stay the same, but results are real records and calls are billed at normal credit rates.

### How is a test key different from a dry run?
A test key runs the call on synthetic data for free. A dry run on a live key returns the exact credit cost of a real call without running it or charging anything.
