# One key per agent. One budget per key.

> Give every Dizo API key its own daily and monthly credit caps, a per-request maximum and an endpoint allow-list. Budget each agent on its own.

Create a key for each agent, workflow or teammate with its own caps and permissions. Spend is attributed per key, limits are enforced per key, and revoking one breaks nothing else.

## Highlights
- **Daily and monthly caps.** `daily_cap_credits` and `monthly_cap_credits` bound what each key can spend.
- **Per-request maximum.** `max_credits_per_request` sets a ceiling on any single call made with the key.
- **Endpoint allow-list.** `allowed_endpoints` limits a key to paths like `/v1/search` and `/v1/email/find`.
- **Scoped access.** Grant only `data:read` for most callers. Billing and key creation need their own scopes.
- **Usage by key.** `GET /v1/billing` shows each key's monthly credits used against its cap.
- **Alerts at 50/80/100%.** Email and webhook alerts fire as any cap fills, before a key stops.

## Steps
1. **Create the key** — Call `POST /v1/keys` or use the console, with a clear `name`.
2. **Set caps and scopes** — Add daily, monthly and per-request caps, `data:read` and an endpoint allow-list.
3. **Store the secret** — The secret is shown once. Put it in your secrets manager.
4. **Watch usage** — Check `GET /v1/billing` per key and route cap alerts to your team.

## 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) |
| Webhooks | `POST /v1/webhooks` | Free | Never | [docs](https://dizo.ai/docs/webhooks.md) |


## Why one account key is not enough

Most teams start with a single API key pasted into everything: a script, a workflow tool, an agent in a chat client, a teammate's notebook. It works until something goes wrong. When the bill jumps, you cannot tell which caller caused it. When an agent misbehaves, revoking its key breaks every other integration. And any caller holding that key can reach every endpoint, including expensive phone lookups it never needed.

Per-key spend caps fix this by making every key its own budget and its own permission set. You create one key per agent, workflow or person, and give each a daily credit cap, a monthly credit cap, a maximum per request and a list of endpoints it may call. Spend is attributed per key, limits are enforced per key, and revoking one key affects only the thing that used it.

## How keys and caps work

Keys are created with `POST /v1/keys`, or in the console under API keys. A call to create one requires a key that itself has the `keys:write` scope. You give the new key a `name`, such as `sdr-agent`, and optionally set the following. The secret is returned once in the response, so store it straight away in your secrets manager.

The console also lets the account owner add an optional IP allowlist and an expiry date to a key, which is useful for contractors and short-lived experiments. Keys are hashed at rest, and every key has its own scopes, as described on the [trust page](/trust).

- **`scopes`:** any of `data:read`, `billing:read`, `billing:write`, `keys:write`.
- **`daily_cap_credits`:** the most credits the key may spend in a day.
- **`monthly_cap_credits`:** the most credits the key may spend in a month.
- **`max_credits_per_request`:** a ceiling on any single call made with the key.
- **`allowed_endpoints`:** the only paths the key may call, such as `/v1/search` and `/v1/email/find`.

## A worked key for an SDR agent

The [keys docs](/docs/keys) show a key named `sdr-agent` with `data:read` only, a daily cap of 2,000 credits, a monthly cap of 20,000, a per-request maximum of 500, and an allow-list of `/v1/search` and `/v1/email/find`. That is a well-shaped key for an outbound agent: it can find people and their work emails, and nothing else.

Translate the caps into money and work. 20,000 credits a month is at most $500 at $0.025 per credit, or $420 if those credits came from a $500 to $1,999 purchase at $0.021. A 2,000-credit day could cover, for example, 25,000 search results (1,000 credits) plus 1,000 emails found (1,000 credits). Because misses are free, a day of email lookups that finds 70% of addresses only draws down the 70%.

The key cannot call the phone finder, change billing or create other keys. If its prompt is manipulated into trying, the request is refused by the allow-list and scopes rather than by the model's judgement.

## Designing a set of keys

A good rule is one key per caller with a distinct purpose. Give each the narrowest endpoint list and the smallest caps that still let it do its job. A hypothetical team might run three:

- **research-agent:** `/v1/search`, `/v1/count`, org chart. Monthly cap 5,000 credits, per-request 200.
- **crm-enrichment:** email find, email verify and batch. Monthly cap 30,000, per-request 10,000 for batch jobs.
- **dialer-sync:** phone find only. Monthly cap 10,000, which is at most 1,000 phones found at 10 credits each.
- **Combined ceiling:** 45,000 credits a month, or $765 if bought in purchases of $2,000 or more at $0.017.

## Seeing what a key can do and has spent

Any key can call `GET /v1/me`, which is free, to see its own name, mode, scopes and allowed endpoints, along with `budget.max_credits_per_request`, `day_remaining_credits` and `month_remaining_credits`, plus its rate limits. The docs example shows 20 requests per second and 10 concurrent. Agents should call it once at start-up and plan within those numbers.

For the account view, `GET /v1/billing` returns per-key usage: each key's name, `month_credits_used` and `month_cap_credits`. The docs show `sdr-agent` at 9,400 of 20,000. That makes attribution simple. When spend rises, you can see which key drove it.

Alerts go out by email and webhook at 50%, 80% and 100% of any cap, so a key approaching its monthly limit is flagged before it stops. The billing webhook events include `billing.cap_warning` and `billing.cap_reached`, which you can route to a team channel or on-call tool through your own [webhook](/docs/webhooks) handler.

## Per-key caps for AI agents

Agents are where per-key caps matter most. Dizo does not let an agent sign itself up or add a payment method; a human owns the account, creates a key for the agent and sets its caps. Over the [MCP server](/mcp), the same rules apply. Clients that support OAuth sign in as the user, and MCP connections default to `data:read` and a 500-credit per-call limit unless changed in the console.

The agent rules ask models to call `dizo_whoami` first, plan within `month_remaining_credits` and `max_credits_per_request`, and stop to ask their human when spend is near a cap. Those instructions work best when the caps are real. A key with an allow-list and a modest monthly cap turns those polite instructions into enforced limits.

Keep billing write access away from agents. Only keys with `billing:write` can top up or change refills, and agents are told to use it only with explicit human approval in the conversation. The simplest policy is never to give an agent that scope at all.

## How key caps fit with other limits

Key caps sit between the request and the account. Below them, a caller can send [`max_credits`](/features/max-credits) on each call for a tighter ceiling than the key allows. Above them, the account has a monthly spend cap in dollars, refills included, and an optional account-wide daily credit limit. A call has to fit inside all of them.

Use each layer for its own job. The request ceiling catches a single bad call. The key's daily cap catches a runaway loop within hours. The key's monthly cap gives each team or agent a budget. The account cap protects the company's total. With all four set, no single mistake can reach further than the layer designed for it.

## Keys per client, team or customer

Caps are not only for agents. An agency running prospecting for several clients can create one key per client, each with a monthly cap that matches that client's retainer. Usage in `GET /v1/billing` then doubles as the basis for passing data costs through, because every credit is already attributed to the right client by key name.

Inside a company, the same pattern gives each team a budget without separate accounts. Sales development, marketing operations and the data team can each hold their own key, with their own caps and endpoint lists, drawing on one shared credit balance and one volume tier. Finance sees a single bill, and each team owner sees their own line.

If you build Dizo data into your own product, the [enterprise](/enterprise) embed licence covers showing Dizo data to your own users, with per-customer keys and caps. The idea is the same: each of your customers gets a key with limits, so one heavy user cannot consume another's allowance.

## Edge cases and good practice

When a key reaches a cap, its billable calls are refused until the cap's period resets, while other keys carry on. Branch on the stable `error.code` and follow the plain-English `error.fix` rather than retrying in a loop; retrying will not help until the period resets or the owner raises the cap.

Separate test from live. Keys that start `dz_test_` return synthetic data and never spend credits, so use them in development and CI, and keep live keys for production. Rotate a key by creating a new one, switching the caller over and revoking the old one; because each caller has its own key, rotation never touches anything else.

[Sign up](/signup) to get a live key and set up your first capped key. Work email signups also get 250 free credits.

## FAQ

### What limits can I set on an API key?
A daily credit cap, a monthly credit cap, a maximum per request, an endpoint allow-list and scopes. The console also supports an optional IP allowlist and expiry.

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

### How do I see how much a key has spent?
`GET /v1/billing` lists each key's `month_credits_used` and `month_cap_credits`. The key itself can call `GET /v1/me` to see its remaining daily and monthly budget.

### Will I be warned before a key hits its cap?
Yes. Alerts go by email and webhook at 50%, 80% and 100% of any cap. Webhook events include `billing.cap_warning` and `billing.cap_reached`.

### Can an agent raise its own caps?
Not unless you give its key `keys:write` or `billing:write`, which you should not. Creating keys requires `keys:write`, and billing changes require `billing:write` plus explicit human approval.

### What happens to other keys when one hits its cap?
Nothing. Caps are per key, so other keys keep working until they reach their own limits or the account's monthly spend cap.

### Should test and live work use different keys?
Yes. Keys starting `dz_test_` return synthetic data and never spend credits, so use them in development and CI. Keep capped `dz_live_` keys for production callers only, one per caller.
