A spend budget caps what an agent can spend, enforced server-side as a per-agent total across every process and restart. An agent with no budget is unlimited until you set one.
How it differs from maxCost
maxCost / X-Max-Cost-USDC caps one call from one process and rejects with 400 exceeds_caller_budget. A budget caps the UTC day and every call, across all processes, survives restarts and rejects with 403 budget_exceeded. Use both.
Enforcement
Every paid route checks the budget before any payment is signed or settled:- Quote-based routes (email, voice, SMS, build, browser, commerce, compute) reject at quote time: you get the
403instead of the402quote. - Fixed-price routes reject before any payment is settled.
- Two parallel calls cannot both fit under the cap. A paid call still in progress counts as
in_flight. - Calls fully covered by credits do not use budget. Failed settlements do not count as spend.
- Sessions paying from credits count credit-funded calls and goals. A goal counts whole from its start; what it returns stops counting.
- A capped agent stays capped during most outages: if the budget, today’s spend or the in-flight reservations cannot be read, the call is held with
503 budget_unavailableand nothing is run or charged. Retry shortly. An agent with no cap is not affected. - Exception: if the budget row itself cannot be read and the cap is not already known from an earlier read, the call goes through instead of being held.
403 budget_exceeded, not a 402. Retrying fails until the window resets or you raise the budget:
reason is daily or per_transaction. The SDKs raise a typed BudgetExceededError with these fields.
When the budget cannot be read
503: the same call can be retried as is. The SDKs surface it as an ordinary request failure, not a BudgetExceededError.
Alerts
Atalert_at the agent gets a budget_warning notification; when a call is blocked, budget_exceeded. Both appear in notifications and are emailed if alert_email is set. Each fires at most once per UTC day.
Authentication
Both endpoints takeX-Agent-ID and a signed x-agent-proof (read proof): scope: "read" for GET, scope: "write" for PUT. Unsigned requests are rejected. The SDKs sign automatically (TypeScript ≥ 0.27.0, Python ≥ 0.20.0) and sync a budgets config once, before the first paid call.