REST API
Cost Budgets
On this page
Set daily and monthly spend caps per workspace. Breaching a cap raises an alert; budgets are advisory and never block traffic.
Get cost budget
HTTP
GET /v1/observ/orgs/{org}/workspaces/{ws}/cost-budget
Auth: API key or JWT · Role: viewer
Response 200 — not schema-modelled
JSON
{
"budgets": {
"day": { "cap_usd": 100.0, "warn_pct": 0.8 },
"month": { "cap_usd": 2500.0, "warn_pct": 0.9 }
},
"current": { "day_spend_usd": 41.29, "month_spend_usd": 892.14 }
}
Examples
b = evigauge.get("/v1/observ/orgs/{org}/workspaces/{ws}/cost-budget")
day = b["budgets"]["day"]
pct = b["current"]["day_spend_usd"] / day["cap_usd"]
print(f"Day: {pct:.0%} of ${day['cap_usd']}", "⚠ WARN" if pct >= day["warn_pct"] else "")
const b = await evigauge.get("/v1/observ/orgs/{org}/workspaces/{ws}/cost-budget");
const day = b.budgets.day;
const pct = b.current.day_spend_usd / day.cap_usd;
console.log(`Day: ${(pct * 100).toFixed(0)}% of $${day.cap_usd}`, pct >= day.warn_pct ? "⚠ WARN" : "");
Set cost budget
HTTP
PUT /v1/observ/orgs/{org}/workspaces/{ws}/cost-budget
Replaces the whole budget object. Omit a period to clear its cap.
Auth: API key or JWT · Role: admin
Request body — CostBudgetIn
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
budgets | object | ✅ | — | Map of period name → PeriodBudget. Keys: day, month |
PeriodBudget
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
cap_usd | number | ✅ | — | Spend cap in USD for the period |
warn_pct | number | ➖ | 0.8 | Fraction of the cap at which to warn (0.0–1.0) |
JSON
{
"budgets": {
"day": { "cap_usd": 150.0, "warn_pct": 0.75 },
"month": { "cap_usd": 3000.0 }
}
}
Examples
evigauge.put("/v1/observ/orgs/{org}/workspaces/{ws}/cost-budget", json={
"budgets": {
"day": {"cap_usd": 150.0, "warn_pct": 0.75},
"month": {"cap_usd": 3000.0}, # warn_pct defaults to 0.8
}
})
await evigauge.put("/v1/observ/orgs/{org}/workspaces/{ws}/cost-budget", {
budgets: {
day: { cap_usd: 150.0, warn_pct: 0.75 },
month: { cap_usd: 3000.0 }, // warn_pct defaults to 0.8
},
});
Errors
| Status | Cause |
|---|---|
403 | Role below admin |
422 | warn_pct outside 0.0–1.0, or cap_usd not a number |