# Hear about spend before it becomes a surprise.

> Dizo emails and webhooks you at 50%, 80% and 100% of any spend cap and on every auto-refill, so an agent never burns through budget unseen.

Set your thresholds once. Dizo sends an email and a signed webhook at 50%, 80% and 100% of any cap, and every time auto-refill buys credits.

## Highlights
- **Three default thresholds.** Alerts fire at **50%, 80% and 100%** of a cap. Change them with `alerts_pct` on the limits endpoint.
- **Every refill reported.** Each auto-refill sends a `billing.refilled` event, so a charge to your card is never silent.
- **Email and webhook.** Name the people in `alert_emails` and point a webhook at your own system. Use either or both.
- **Account and per-key caps.** Alerts cover the account monthly cap and the daily and monthly caps on each key.
- **Signed deliveries.** Webhooks carry a `Dizo-Signature` HMAC header and retry with backoff for 24 hours.
- **Free to use.** Limits, webhooks and billing reads cost nothing. Alerts never use credits.

## Steps
1. **Set a cap** — `PUT /v1/billing/limits` with a `monthly_cap_usd`.
2. **Pick thresholds and recipients** — Add `alerts_pct` and `alert_emails` in the same call.
3. **Register a webhook** — `POST /v1/webhooks` with the `billing.*` events you want.
4. **Route and act** — Verify the signature, post to your team channel, and pause jobs at 100%.

## APIs used
| API | Endpoint | Credits | Charged | Reference |
|---|---|---|---|---|
| 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) |
| Balance & usage | `GET /v1/billing` | Free | Never | [docs](https://dizo.ai/docs/billing.md) |
| Auto-refill | `PUT /v1/billing/auto-refill` | Free | Never | [docs](https://dizo.ai/docs/billing-refill.md) |


## Why spend needs a warning system, not just a ceiling

A hard cap stops spending. It does not tell anyone that spending is happening. When a person runs searches in a browser, they see every result and roughly know what it cost. When an agent runs a prospecting loop overnight, or a nightly sync enriches every new CRM record, nobody is watching the meter. The first sign of a runaway job is often the cap itself, at which point calls start failing and the work stops halfway.

Spend alerts fill that gap. Dizo sends an email and a webhook when usage crosses 50%, 80% and 100% of any cap you set, and every time auto-refill buys credits. The 50% alert is a pacing check. The 80% alert is the moment to decide whether to raise the cap or slow the job down. The 100% alert confirms that the ceiling held. Each one reaches you while there is still time to act, rather than after a quiet month-end invoice.

Alerts cost nothing. The limits endpoint, the webhooks endpoint and the billing reads are all free, so there is no reason to run an account without them.

## What triggers an alert

There are two kinds of trigger. The first is a threshold on a cap. Your account has a monthly cap in US dollars, refills included, and an optional daily credit limit. Each API key can also have its own daily and monthly credit caps. Alerts fire at the percentages in `alerts_pct`, which default to 50, 80 and 100, for any of those caps.

The second trigger is money moving. Every auto-refill sends an alert, whether or not any cap is close. If you set a refill to charge $500 when your balance falls below 5,000 credits, you hear about each of those $500 charges as it happens. On the webhook side these map to named events you can subscribe to individually:

- `billing.cap_warning`: usage crossed one of your warning thresholds.
- `billing.cap_reached`: a cap was hit and calls on it now return `402 monthly_cap_reached` or stop at the key limit.
- `billing.refilled`: auto-refill bought credits at the tier for its amount.
- `billing.low_balance`: your balance is running low.

## Setting thresholds and recipients

Alerts live on the same endpoint as the account cap: `PUT /v1/billing/limits`. A typical body sets `monthly_cap_usd` to 2000, `alerts_pct` to `[50, 80, 100]` and `alert_emails` to a shared finance or ops address. You can send any thresholds you like. A team that wants an early nudge might use `[25, 50, 80, 100]`; a team that only cares about the ceiling might use `[90, 100]`. The response echoes back the limits as stored, so you can confirm the change in code.

Use a shared inbox for `alert_emails` rather than one person. Caps get hit on weekends and during holidays, and an alert that lands in the inbox of someone on leave does not help. If you also lock billing with `locked: true`, no API key can change these settings afterwards, which stops an agent from quietly turning its own alerts off.

Changing limits requires a key with billing write permission. Agents should never call it without explicit human approval, and the account owner can block it entirely with the lock.

## Receiving alerts as webhooks

Email is for people. Webhooks are for systems. Register an HTTPS endpoint once with `POST /v1/webhooks`, list the events you care about in `events`, and Dizo posts a signed payload whenever one fires. If you leave `events` out, you get every event type, including `batch.completed` and `signal.job_change`, so name the `billing.*` events explicitly if this endpoint is only for spend.

Every delivery has a `Dizo-Signature` header made of a `t=` Unix timestamp and a `v1=` signature, where the HMAC is SHA-256 over the timestamp, a dot and the raw body, keyed with your signing secret. Check it before you trust the payload. The secret is shown once when you create the webhook; rotate it with `POST /v1/webhooks/{id}/rotate` if it ever leaks. Failed deliveries are retried with backoff for 24 hours, so a short outage on your side does not lose an alert.

From your handler you can do whatever fits: post to a team channel, open a ticket, page whoever owns the agent, or flip a feature flag that pauses scheduled jobs. A workflow tool such as [n8n](/integrations/n8n) can sit in the middle if you would rather not write the handler yourself. The [webhooks reference](/docs/webhooks) lists the event names and the signature format.

## A worked example: one month with a $2,000 cap

Take a hypothetical team with a $2,000 monthly cap, alerts at 50, 80 and 100, and auto-refill set to charge $500 whenever the balance drops below 5,000 credits. A $500 purchase falls in the Builder tier at $0.021 per credit, so each refill adds about 23,809 credits. Four refills would reach the $2,000 cap.

Early in the month the first refill fires and the team gets a `billing.refilled` email: $500 charged. That is the 25% mark of the cap, so no threshold alert yet. The second refill brings spend to $1,000, which is exactly 50% of the cap, and both a refill alert and a 50% alert arrive. If that happened in the first week, the team knows the pace would blow through the cap long before month end.

At $1,500 there is a third refill alert. The next threshold, 80%, is $1,600, which spend crosses as soon as the team uses about 4,762 credits of the third refill. At that point a person decides: raise the cap, slow the nightly enrichment, or let it run to $2,000 and stop. If nobody acts, the fourth refill takes spend to the cap, the 100% alert fires, and calls return `402 monthly_cap_reached` once the balance runs out. Every step was visible.

## How agents fit in

Alerts are aimed at the humans who own the budget. Agents should not wait for them. The Dizo rules for agents say to check `GET /v1/billing` before long loops and stop to ask a human if monthly spend is near the cap. Over MCP the same read is the free `dizo_balance` tool, and `dizo_whoami` returns the key's remaining daily and monthly budget.

The two work together. The agent checks its budget before a big job and plans inside it. The alerts tell a person when total usage across every key and every job crosses a line. An agent can be well behaved and still be one of five jobs that together push the account to 80%. Only the account-level alert sees that.

If you build your own agent loop, you can also subscribe it to `billing.cap_warning` and have it switch to a cheaper mode, for example running searches only and skipping phone lookups, until a person reviews. Treat that as a courtesy layer; the cap and the per-key limits remain the hard controls.

## Alerts alongside caps, refills and keys

Alerts never block a call by themselves. They report on the controls that do. The [monthly spend cap](/features/monthly-spend-cap) is the account-wide ceiling. [Per-key spend caps](/features/per-key-spend-caps) give each agent or integration its own daily and monthly budget. `max_credits` on a single request stops one call from overspending. Auto-refill keeps the balance topped up but is skipped if a refill would push the month over the cap, and that skipped refill is itself reported.

A sensible setup for a small team is one account cap with alerts at 50, 80 and 100, a per-key monthly cap on every agent key, and a shared email plus one webhook for the `billing.*` events. Give each key a name that says who owns it, such as `sdr-agent` or `nightly-sync`, so the per-key usage in `GET /v1/billing` points straight at the job responsible when an alert arrives.

## Edge cases worth knowing

A cap measured in dollars and a cap measured in credits behave differently. The account monthly cap is in US dollars and counts refills, while key caps count credits used. A key can hit its own 100% while the account is only at 30%, and the other keys keep working.

Alerts report thresholds crossed, not individual calls. A single large batch can move usage from below 50% to above 80% in one step, in which case both alerts arrive close together. If you want tighter control over large jobs, quote them first with `dry_run` and set `max_credits` on the request.

Remember that a refill alert is about money, while threshold alerts are about usage against a cap. If you run without auto-refill, you will never see `billing.refilled`, but `billing.low_balance` still tells you when the balance needs a manual top-up.

## When you may not need it

If you only ever buy credits by hand, never turn on auto-refill and run every search yourself in a chat client, your balance is the limit and you see every call. Alerts still help, but they add little. The moment anything runs without a person watching, such as an agent, a cron job or a batch triggered by a form, turn them on. They take one request to configure and cost nothing. See [pricing](/pricing) for how refills are priced by tier.

## FAQ

### Which thresholds can I set?
Any percentages you list in `alerts_pct` on `PUT /v1/billing/limits`. The default is 50, 80 and 100. They apply to the account cap and to per-key caps.

### Do I get an alert on every auto-refill?
Yes. Every refill sends an email and a `billing.refilled` webhook, whether or not you are near a cap. If a refill is skipped because it would exceed the monthly cap, you are alerted about that too.

### Do alerts stop spending?
No. Alerts report; caps enforce. When a cap is reached, calls return `402 monthly_cap_reached` or stop at the key limit, and the 100% alert tells you that happened.

### Who receives the emails?
The addresses in `alert_emails`. Use a shared inbox so alerts are seen even when one person is away.

### How do I check a webhook is really from Dizo?
Verify the `Dizo-Signature` header: an HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the signing secret you got when you created the webhook.

### Can an agent turn off its own alerts?
Only with a key that has `billing:write`, and agents are instructed never to change billing without human approval. Set `locked: true` and no key can change billing settings at all.
