# API key

> A secret token a client sends with each request so an API knows who is calling and what they are allowed to do.

An API key is a long, random secret that identifies a caller. The client sends it with every request, usually in an `Authorization: Bearer` header, and the server looks it up to decide which account to bill and which actions to allow. Anyone holding the key can act as that caller, which is why keys are treated like passwords.

Modern APIs attach permissions to each key rather than to the whole account. A key can be limited to read-only scopes, a short list of endpoints, a spending cap or a set of IP addresses. That makes it safe to give a narrow key to a script, a teammate or an AI agent without exposing everything else.

Good key hygiene is simple: one key per integration, never in source control or client-side code, stored in a secrets manager or environment variable, and rotated whenever someone who had access leaves. A leaked key with tight limits is an inconvenience; a leaked unrestricted key is an incident.

## How Dizo handles it
Dizo keys start with `dz_live_` or `dz_test_`. Test keys return synthetic data and never spend credits. Each live key can have scopes (`data:read`, `billing:read`, `billing:write`, `keys:write`), daily and monthly credit caps, a per-request ceiling, an endpoint allow-list, an optional IP allowlist and expiry. The secret is shown once and keys are hashed at rest. `GET /v1/me` returns what a key can do.

Docs: [/docs/keys](https://dizo.ai/docs/keys.md), [/docs/me](https://dizo.ai/docs/me.md), [/docs/billing-limits](https://dizo.ai/docs/billing-limits.md)

Related terms: [OAuth](https://dizo.ai/glossary/oauth.md), [Rate limit](https://dizo.ai/glossary/rate-limit.md), [API credits](https://dizo.ai/glossary/credits.md), [AI agent](https://dizo.ai/glossary/ai-agent.md)


## What an API key is

An API key is a secret string that a program sends with its requests to prove who it is. The server receives the key, looks up which account and permissions it belongs to, and then decides whether to run the request and whom to bill. Most APIs expect the key in an HTTP header, typically `Authorization: Bearer dz_live_...` or a similar provider-specific format, rather than in the URL, where it could end up in logs and browser history.

Keys are long and random so they cannot be guessed. Many providers add a readable prefix that says what kind of key it is, which helps humans and secret scanners spot one in the wild. The rest of the string is the secret itself, and the provider usually shows it only once, at creation time.

An API key identifies a caller, not a person. It does not ask anyone to log in, and it works the same way whether a developer, a cron job or an AI agent is using it. That simplicity is why keys are the default for server-to-server access, and also why they need limits.

## Why API keys matter for GTM teams and AI agents

On a paid data API, a key is effectively a payment instrument. Whoever holds it can spend the account's balance. In a GTM stack that might mean a RevOps script, an enrichment workflow, a sales engineer testing in a notebook and an AI SDR, all calling the same provider. If they share one key, you cannot tell who spent what, and you cannot revoke one without breaking the others.

AI agents make this more pressing. An agent decides at runtime which calls to make and how many. A bug, a bad prompt or a loop can turn a ten-credit task into a ten-thousand-credit one. The key is the natural place to put hard boundaries, because the server enforces them no matter what the agent intends.

The practical goal is that every key has the minimum access its job needs. The [scoped API keys](/features/scoped-api-keys) page shows how that principle looks when it is built into the key itself.

## How API keys work, mechanically

When you create a key, the provider generates a random secret, shows it to you once, and stores only a hashed version. On each request, the server hashes the key it receives and compares it with the stored hash. If they match, the request is authenticated as that key. Because only the hash is stored, a database leak at the provider does not reveal usable keys.

Once authenticated, the server applies the key's rules in order: is the key active and not expired, is the request coming from an allowed IP, is this endpoint on the key's allow-list, does the key have the needed scope, and would this request exceed any credit cap. A request that fails any check is rejected with an error before any work or billing happens.

Common restrictions you can attach to a key:

- **Scopes:** which categories of action are allowed, such as reading data versus changing billing.
- **Endpoint allow-list:** the exact paths the key may call.
- **Spend caps:** limits per request, per day and per month.
- **IP allowlist:** only accept requests from known server addresses.
- **Expiry:** the key stops working after a set date.

## Common mistakes with API keys

The classic mistake is committing a key to a repository. Even a private repository gets cloned, forked and shared, and keys in old commits stay in the history after you delete them. Keep keys in environment variables or a secrets manager, add your secret files to `.gitignore`, and use a scanner that flags key-shaped strings before they are pushed.

Another mistake is putting a key in browser or mobile code. Anything shipped to a user's device can be read by that user. If a front end needs data, route the request through your own server, which holds the key and decides what to return.

The third mistake is one key for everything. A shared key makes usage impossible to attribute, forces you to rotate every integration at once when it leaks, and gives every caller the widest permissions any of them needs. One key per integration, named after its job, avoids all three problems.

## How to evaluate an API's key model

When you compare data providers, the key model is a good signal of how seriously they take automated access. Check whether you can create multiple keys, whether each key can have its own permissions and caps, and whether there is a separate test mode that cannot spend money. Those features decide how safely you can give access to agents and teammates.

Also check visibility. A good API lets a key report its own permissions and remaining budget, and shows per-key usage in billing. That lets you answer which integration spent the money without digging through logs.

Finally, check the recovery path: how fast you can revoke a key, whether revocation is immediate, and whether the provider stores keys hashed. Those details matter most on the one day a key leaks.

## How API keys work in Dizo

Dizo has two kinds of key. Keys starting with `dz_test_` return synthetic data and never spend credits, so you can build and test an integration before you have live access. Keys starting with `dz_live_` return real data and spend credits. You get a live key when you [sign up](/signup).

Keys are created in the console or with `POST /v1/keys`, which requires the `keys:write` scope. Each key has a `name` and can carry `scopes` (`data:read`, `billing:read`, `billing:write`, `keys:write`), `daily_cap_credits` and `monthly_cap_credits`, a `max_credits_per_request` ceiling and an `allowed_endpoints` list. Keys can also have an optional IP allowlist and expiry. The secret is returned once, and keys are hashed at rest.

Any key can call `GET /v1/me`, which is free and returns the key's scopes, endpoint allow-list, remaining daily and monthly budget, and rate limits. Billing is read-only for keys by default, and only a key with `billing:write` can top up or change refills. The [keys reference](/docs/keys) lists every parameter.

## A safe key setup for an AI agent

A sensible pattern is one key per agent with only what that agent needs. An AI SDR that searches and finds emails might get `data:read`, an allow-list of `/v1/search` and `/v1/email/find`, a 500-credit per-request ceiling, a 2,000-credit daily cap and a 20,000-credit monthly cap. Even if its prompt goes badly wrong, it cannot change billing, create keys or spend past those limits.

In cost terms, that 20,000-credit monthly cap is $500 at the pay-as-you-go rate of $0.025 per credit, or $340 at the Growth rate of $0.017. Pick the cap from the budget you are willing to lose in the worst case, not from what you expect to spend.

Have the agent call `GET /v1/me` at start-up and plan within the remaining budget it reports. When the agent needs to work through MCP in a client that supports sign-in, OAuth can replace the pasted key entirely.

## Rotating keys without downtime

Rotation means replacing a key with a new one on a schedule or after any possible exposure. The safe order is always create first, switch second, revoke last. Create the new key with the same limits, deploy it to the integration, confirm requests are succeeding with it, and only then revoke the old key. Doing it the other way round causes an outage for every caller still holding the old secret.

Rotation is much easier when each integration has its own key. You can rotate the enrichment job's key on a Tuesday afternoon without touching the AI SDR or the CRM sync. Name keys after their job and owner, so that when someone leaves the company you know exactly which keys to rotate and who to ask.

## Related concepts

[OAuth](/glossary/oauth) is the main alternative to pasting a key: the user signs in and approves access, and the client receives a token instead of a long-lived secret. Rate limits are usually applied per key, so separate keys also isolate one integration's traffic from another's.

Credits and spend caps connect keys to money. Idempotency keys, despite the name, are unrelated to authentication: they are per-request values that make retries safe.

## FAQ

### Where should I store an API key?
In an environment variable or a secrets manager on the server that makes the calls. Never commit it to a repository or ship it in browser or mobile code, where anyone can read it.

### What should I do if an API key leaks?
Revoke it immediately, create a replacement, and update the one integration that used it. If every integration shares the key, you have to update all of them, which is a good reason to use one key per integration.

### What is the difference between an API key and OAuth?
An API key is a long-lived secret you paste into a tool. OAuth has a user sign in and approve access, and the tool receives a token instead. OAuth suits interactive apps; keys suit servers, scripts and agents you control.

### What can a Dizo test key do?
Keys starting with `dz_test_` return synthetic data and never spend credits. They let you build and test an integration, including error handling, before you have live access.

### Can I stop an agent's key from changing billing?
Yes. Dizo keys are read-only for billing by default, and only keys with the `billing:write` scope can top up or change refills. The account owner can also lock billing entirely.

### How does an agent know what its key allows?
It calls `GET /v1/me`, which is free. The response lists the key's scopes, allowed endpoints, remaining daily and monthly budget, per-request ceiling and rate limits.
