Budgets
Set a daily or monthly spend budget in US dollars for your organization, a workspace or an environment, get email alerts as it fills, and optionally stop priced work when it is used up.
On this page
A budget is a spend limit in US dollars for one day or one calendar month (UTC), for your whole organization, one workspace or one environment. Hexel Studio emails the address on your billing profile (and its cc addresses) as spend reaches the budget's alert percentages. An enforced budget is also a hard stop: once it is used up, priced work in its scope is refused.
Create a budget
With the Hexel CLI 0.11.1 or later:
# $500 a month for the whole organization, alerts at 80% and 100%
hexel billing budget create --name "Org monthly" --usd 500
# A hard stop: $25 a day for one environment
hexel billing budget create --name "Prod daily" --usd 25 --period day \
--scope environment --env env_prod --enforce
# A workspace budget with your own alert percentages
hexel billing budget create --name "Team" --usd 100 --scope workspace --alert 50,90,100hexel billing budgets lists every budget with what it has spent this period; hexel billing budget update <ID> changes only the flags you pass, and hexel billing budget delete <ID> removes one.
curl -X POST https://api.hexelstudio.com/v1/billing/budgets \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Prod daily",
"scope": "environment",
"workspace_id": "ws_7f2",
"environment_id": "env_prod",
"usd_micros": 25000000,
"period": "day",
"enforce": true,
"alert_percents": [80, 100]
}'The answer is 201 with the budget and its budget_id.
Fields
| Field | Meaning |
|---|---|
name | 1 to 200 characters. |
scope | org, workspace or environment. A workspace budget takes workspace_id; an environment budget takes workspace_id and environment_id; an organization budget takes neither. |
usd_micros | The limit in millionths of a US dollar, more than 0. 25000000 is $25. |
period | day or month, in UTC. |
enforce | true makes the budget a hard stop. Default false: alerts only. |
alert_percents | Percentages of the limit (1 to 1000) at which an alert is emailed, each at most once a period. When spend jumps past several at once, only the highest is sent. Default [80, 100]. |
You can have one budget per scope and period: a second one for the same workspace and period is refused with 409 budget_exists.
Read and change budgets
| Method and path | What it does | Permission |
|---|---|---|
GET /v1/billing/budgets | Every budget with spent_usd_micros, period_start and period_end | org:billing:read |
GET /v1/billing/budgets/{budget_id} | One budget with its spend this period | org:billing:read |
POST /v1/billing/budgets | Create a budget | org:billing:manage |
PUT /v1/billing/budgets/{budget_id} | Replace every setting of a budget | org:billing:manage |
DELETE /v1/billing/budgets/{budget_id} | Delete a budget; alerts already queued are still sent | org:billing:manage |
Spend so far is the larger of the settled cost and the real-time counter for the period, so a budget still counts while usage is being settled. After a PUT, alerts already sent this period are not sent again for the same percentages.
Errors have the body {"error": "<code>", "message": "..."}: 400 invalid_request for a field that breaks the rules above, 404 budget_not_found, 409 budget_exists, and 503 when billing can't be read (try again).
What an enforced budget stops
When an enforced budget that covers the request (the organization's, its workspace's or its environment's) is used up, or the request's estimated cost would pass it, Hexel Studio refuses the priced request with the reason budget_exceeded. Requests that are not priced, such as reading your settings, are never refused by a budget.
Titan governed actions
Titan checks your plan before it lets an agent act:
- Monthly governed-action limit. A plan that sets a monthly limit on governed actions (the trial does) refuses the action once the limit is reached, with
409 GOVERNED_ACTION_LIMIT_REACHED, before anything runs. The agent gets the refusal on its call. The refusal is not written to the Agent Ledger; only plan refusals (402) are. - Enforced budgets. Titan Cloud does not yet stop governed actions on an enforced budget: governed actions still count toward your budgets' spend and alerts. When this is turned on, an action refused by a budget will answer
409 GOVERNED_ACTION_BUDGET_EXCEEDED.
If billing can't be reached, a governed action goes ahead and is still metered and billed afterwards.
See also
- Errors for Titan's error codes.
- Kill switch to stop an agent at once, whatever it has spent.