DEVELOPER DOCS

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 "")

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

FieldTypeRequiredDefaultDescription
budgetsobject✅—Map of period name → PeriodBudget. Keys: day, month

PeriodBudget

FieldTypeRequiredDefaultDescription
cap_usdnumber✅—Spend cap in USD for the period
warn_pctnumber➖0.8Fraction 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
    }
})

Errors

StatusCause
403Role below admin
422warn_pct outside 0.0–1.0, or cap_usd not a number