# Every agent gets only the access it needs.

> Give every agent its own Dizo key with scopes like data:read or billing:write, an endpoint allow-list, credit caps, an IP allowlist and an expiry.

Create a key per agent, teammate or integration. Choose its scopes, list the endpoints it may call and cap what it can spend. Nothing else is reachable.

## Highlights
- **Four scopes.** `data:read`, `billing:read`, `billing:write` and `keys:write`. Grant only what the job needs.
- **Endpoint allow-list.** `allowed_endpoints` limits a key to specific paths, such as `/v1/search` and `/v1/email/find`.
- **Credit caps per key.** Daily and monthly credit caps, plus `max_credits_per_request`, set on the key itself.
- **IP allowlist and expiry.** Optionally pin a key to known IPs and give it an end date.
- **Self-describing.** `GET /v1/me` tells the agent its scopes, allow-list, remaining budget and rate limits.
- **Hashed at rest.** The secret is shown once at creation. Dizo stores keys hashed.

## Steps
1. **Name the job** — One key per agent or integration, labelled so usage is traceable.
2. **Pick scopes and endpoints** — Usually `data:read` plus a short `allowed_endpoints` list.
3. **Set caps** — Daily, monthly and per-request credit limits.
4. **Hand it over** — Store the secret once; the agent calls `GET /v1/me` at start-up.

## APIs used
| API | Endpoint | Credits | Charged | Reference |
|---|---|---|---|---|
| API keys | `POST /v1/keys` | Free | Never | [docs](https://dizo.ai/docs/keys.md) |
| Key info | `GET /v1/me` | Free | Never | [docs](https://dizo.ai/docs/me.md) |
| Balance & usage | `GET /v1/billing` | Free | Never | [docs](https://dizo.ai/docs/billing.md) |
| Spend limits | `PUT /v1/billing/limits` | Free | Never | [docs](https://dizo.ai/docs/billing-limits.md) |


## One shared key is a single point of failure

Most teams start with one API key pasted into every script, agent and spreadsheet. It works until something goes wrong. A prompt-injected agent tries an endpoint it was never meant to use. A leaked key in a public repo starts running phone lookups. Finance asks which tool spent last month's budget and nobody can say, because every request looks the same. Rotating that one key breaks everything at once.

Scoped keys fix this by making access granular. Each key has a name, a set of scopes, an optional list of endpoints it may call, its own credit caps and, optionally, an IP allowlist and an expiry date. You create one per agent, per teammate or per integration. If one is misused, you revoke it and nothing else notices. If you want to know who spent what, per-key usage is already broken out in `GET /v1/billing`.

This matters more for agents than for people. An agent follows instructions it reads, including instructions from web pages and documents it was never meant to obey. The narrower its key, the less a bad instruction can do.

## The four scopes

Scopes decide which families of endpoints a key may touch. There are four. `data:read` covers the data APIs: search, enrichment, email and phone lookups, verification and the rest. `billing:read` lets a key see balance, spend and refill settings. `billing:write` lets it top up, change auto-refill and change spend limits. `keys:write` lets it create further keys.

Keys are read-only for billing by default, and the account owner can lock billing entirely, in which case no key can change it, whatever its scopes. MCP connections start with `data:read` only and a 500-credit per-call limit unless you change that in the console.

A useful rule: almost every agent needs `data:read` and nothing more. A finance dashboard needs `billing:read`. Only an admin tool that a human operates needs `billing:write` or `keys:write`, and even then the Dizo agent rules say billing writes require explicit human approval in the conversation.

## Endpoint allow-lists

Scopes are broad. `allowed_endpoints` is precise. It is a list of paths the key may call, and anything else is refused. An outbound agent that only needs to search and find emails can be limited to `/v1/search` and `/v1/email/find`. It then cannot run a 10-credit phone lookup, even if a prompt tells it to.

Allow-lists are the cheapest way to control cost by design rather than by cap. Phone finder is ten times the price of email finder, and person enrich with phone adds 10 credits on top of the base 2. If a workflow has no reason to dial, leave the phone paths off its key. If a CRM sync only enriches companies, give it `/v1/companies/enrich` and the domain-to-company path, and nothing about people.

Free endpoints are worth including. `GET /v1/me` and `POST /v1/count` cost nothing and help an agent plan, so add them to most allow-lists.

## Caps, IP allowlist and expiry

Each key carries its own spending limits: `daily_cap_credits`, `monthly_cap_credits` and `max_credits_per_request`. These sit under the account-wide monthly cap, so a key can never spend more than the account allows, and one busy key cannot starve the others beyond its own budget. Details are on the [per-key spend caps](/features/per-key-spend-caps) page.

Two further controls are optional. An IP allowlist ties a key to the addresses your servers run from, so a copy of the secret used from anywhere else is useless. An expiry date suits contractors, pilots and short experiments: the key simply stops working on the day you choose, and you do not have to remember to revoke it.

The secret is returned once, at creation, and Dizo stores keys hashed at rest. Put it in your secret manager straight away. If you lose it, create a new key rather than looking for the old one.

## Creating a key

Keys are created with `POST /v1/keys`, which itself requires the `keys:write` scope. A typical body for an outbound agent names the key `sdr-agent`, grants `["data:read"]`, sets `daily_cap_credits` to 2000, `monthly_cap_credits` to 20000 and `max_credits_per_request` to 500, and allows `/v1/search` and `/v1/email/find`. The response returns an `id`, the `name` and the `secret`, which starts with `dz_live_` and is shown only that once.

You can do the same from the console under API keys. Either way, the human who owns the account creates the key and hands it to the agent. Dizo does not let an agent sign itself up or add a payment method. Full parameters are in the [keys reference](/docs/keys).

## What the agent sees

An agent should never have to guess what it may do. `GET /v1/me` returns the key's `mode`, `scopes`, `allowed_endpoints`, its budget (`max_credits_per_request`, `day_remaining_credits`, `month_remaining_credits`) and its rate limits. Over MCP the same call is `dizo_whoami`. The Dizo agent rules say to call it once at start-up and plan within the budget it reports.

That turns limits into information instead of surprises. An agent told to build a list of 2,000 contacts with emails can read that it has 1,640 credits left today, see that the job would need more, and ask its human whether to split the work over two days. Without that call, it would simply run until it hit the cap and stop halfway through.

The free [MCP server](/mcp) uses the same key model. Connect a client with a scoped key in the `Authorization` header, or through OAuth, and every tool call is checked against that key's scopes, allow-list and caps.

## A worked example: three keys for one small team

Picture a hypothetical team running three things. An outbound agent searches and finds emails. A nightly job enriches new CRM accounts. A finance dashboard shows spend. They buy credits at the Builder tier, $0.021 each.

The outbound agent gets `data:read`, an allow-list of search, email find, count and me, a daily cap of 2,000 credits and a monthly cap of 20,000. Its worst possible month costs 20,000 × $0.021 = $420, and its worst day about $42. The CRM job gets `data:read`, an allow-list of company enrich and domain to company, and a monthly cap of 5,000 credits: at most 5,000 matched companies, or $105. The dashboard gets `billing:read` only and no data endpoints at all.

None of the three can top up, change refills or create keys. If the outbound agent's key leaks, the damage is bounded at $42 a day and it cannot touch phone data. Revoking it leaves the CRM job and the dashboard running.

## Rotation, offboarding and per-customer keys

Because each key does one job, rotating it is a small event. Create the replacement with the same scopes, allow-list and caps, deploy it to the one service that uses it, confirm traffic has moved by watching that key's usage in `GET /v1/billing`, then revoke the old one. Nothing else changes. Do this on a schedule for long-lived server keys, and immediately whenever a secret might have been exposed in logs, screenshots or a commit.

Offboarding follows the same logic. When a teammate leaves or a contractor's project ends, revoke the keys that carry their name. If you set an expiry when you created them, that already happened on its own. Naming keys after people and jobs, rather than calling them `key1` and `key2`, is what makes this a two-minute task instead of an investigation.

Teams that show Dizo data inside their own product take the idea one step further. The embed and OEM licence on the [enterprise](/enterprise) plan supports per-customer keys and caps, so each of your customers draws from its own budget and can be cut off without affecting the rest.

## Common mistakes

Each of these is cheap to avoid at creation time and expensive to unwind later. The pattern that holds up is boring on purpose: one job, one key, the smallest scopes, the shortest allow-list and caps sized to a bad day rather than a good one.

- Reusing one key across agents, which hides who spent what and makes rotation painful.
- Granting `billing:write` to an agent just in case. Agents should ask a human, not top up.
- Leaving `allowed_endpoints` empty on a key that only needs two paths.
- Storing the secret in a prompt or a shared document instead of a secret manager.
- Forgetting expiry on keys made for pilots and contractors.
- Not locking billing on an account where several people hold keys with write scopes.

## When a single key is fine

If you are one person trying Dizo from a single script on your laptop, one key with sensible caps is enough. Better still, start with a `dz_test_` key, which returns synthetic data and never spends credits. Split into scoped keys the moment a second job, a second person or any unattended agent appears. [Sign up](/signup) to get live keys.

## FAQ

### What scopes are available?
`data:read`, `billing:read`, `billing:write` and `keys:write`. Most agents need only `data:read`.

### Can a key be limited to specific endpoints?
Yes. Set `allowed_endpoints` to a list of paths, for example `/v1/search` and `/v1/email/find`. Calls to anything else are refused.

### How does an agent learn what its key allows?
It calls `GET /v1/me`, or `dizo_whoami` over MCP. The response lists scopes, the allow-list, remaining daily and monthly budget, the per-request limit and rate limits.

### Can I see the secret again later?
No. The secret is shown once when the key is created, and keys are stored hashed. Create a new key if you lose it.

### Can an agent create its own keys?
Only with `keys:write`, which you should not give to agents. A human owns the account, creates keys and sets their caps.

### What scope does an MCP connection get?
MCP connections default to `data:read` and a 500-credit per-call limit unless you change that in the console.
