How do I…
How do I cap my spending?
Set a monthly and a daily limit for background jobs and batches, so a mistake in a loop cannot spend your whole credit. A job that would go over the limit is refused before it starts.
Steps
- Set the limits in the portal (Billing) or from code – in your billing currency.
- Check what you have spent this month.
- Remove a limit with an empty value when you no longer need it.
No code: copy this into Claude or ChatGPT with WBX Sandbox connected and change it to fit.
What is my WBX budget, and how much have I spent this month?
An assistant can show the budget but not change it – set the limits in the portal under Billing, or from code.
pip install wbxsandbox, your key in WBXSANDBOX_API_KEY.
from wbxsandbox import get_budget, set_budget set_budget(monthly="20", daily="2") # in your billing currency (CZK: e.g. "500" and "50") b = get_budget() print(b["currency"], b["monthly_limit"], b["spent_this_month"]) set_budget(daily="") # "" removes a limit
npm install wbxsandbox (Node.js 20+); save as .mts for top-level await.
import { WBX } from "wbxsandbox";
const wbx = new WBX();
await wbx.budget.update({ monthly: "20", daily: "2" }); // in your billing currency (CZK: e.g. "500" and "50")
const b = await wbx.budget.get();
console.log(b.currency, b.monthly_limit, b.spent_this_month);
await wbx.budget.update({ daily: "" }); // "" removes a limit
Just curl and jq; your key in WBXSANDBOX_API_KEY.
H="Authorization: Bearer $WBXSANDBOX_API_KEY"
curl -s -X PUT https://sandbox.wbx.cz/v1/budget -H "$H" -d '{"monthly_limit": "20", "daily_limit": "2"}' # CZK: e.g. "500" and "50"
curl -s https://sandbox.wbx.cz/v1/budget -H "$H"
How to tell it worked
- The answer shows your limits and
spent_this_month. - A job whose price limit does not fit into what is left is refused with
402 budget_exceeded.
If it doesn't work
| What you see | What to do |
|---|---|
402 budget_exceeded | The limit works. Raise it, wait for the next day or month, or lower the job's max_cost. |
| Sandboxes still cost money | Budgets cover jobs and batches only – also those an assistant starts. Sandboxes are limited by your plan and your credit. |
| The amounts look wrong | Limits are in your billing currency (USD, EUR or CZK). |
What it costs
Setting a budget is free. The daily limit counts by UTC days.