Skip to contentSkip to page list

Docs

Update budget

Partial update. Scope, window and cycle_anchor_at are immutable after create. Answers with the budget's live spend, the same figure GET /budgets reports. Requires gatewayBudgets:update at the organization.

PATCH/api/gateway/v1/budgets/{id}
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/gateway/v1/budgets/<id>"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,}​response = requests.patch(    origin + path,    headers=headers,)print(response.json())

Success

application/json · Generated from schema

{  "budget": {    "id": "string",    "organization_id": "string",    "scope_type": "organization",    "scope_id": "string",    "name": "string",    "description": "string",    "window": "minute",    "on_breach": "block",    "limit_usd": "string",    "limit_nano_usd": -9007199254740991,    "spent_usd": "string",    "spent_nano_usd": -9007199254740991,    "timezone": "string",    "provider_key": "string",    "external_id": "string",    "metadata": {},    "current_period_started_at": "string",    "resets_at": "string",    "cycle_anchor_at": "string",    "last_reset_at": "string",    "archived_at": "string",    "created_at": "string",    "member_count": -9007199254740991,    "end_users_seen": -9007199254740991,    "end_users_over": -9007199254740991,    "scope_reach": "reachable"  }}
api-reference/gateway-budgets/update-budget

Authorization

X-Auth-Tokenstringheaderrequired

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

Path parameters

idstringrequired
At least 1 character

Request body

application/json

namestring
At least 1 characterUp to 128 characters
descriptionstring | null
limit_usdnumber | string
Option 1number
Option 2string
on_breachstring
One of"block""warn"
timezonestring | null
external_idstring | null
Option 1string
Option 2null
metadataobject

Responses

200

Success

application/json

budgetobjectrequired
idstringrequired
organization_idstringrequired
scope_typestringrequired
One of"organization""team""project""virtual_key""principal""group""attributed_user"
scope_idstringrequired
namestringrequired
descriptionstring | nullrequired
windowstringrequired
One of"minute""hour""day""week""month""total""manual"
on_breachstringrequired
One of"block""warn"
limit_usdstringrequired

Display value. Decimal string, up to 9 fractional digits, trailing zeros trimmed, never exponent notation. Use limit_nano_usd for arithmetic.

limit_nano_usdinteger | nullrequired
spent_usdstring | nullrequired
spent_nano_usdinteger | nullrequired
timezonestring | nullrequired
provider_keystring | nullrequired
external_idstring | nullrequired
metadataobjectrequired
current_period_started_atstringrequired
resets_atstringrequired
cycle_anchor_atstring | nullrequired
last_reset_atstring | nullrequired
archived_atstring | nullrequired
created_atstringrequired
member_countinteger
Minimum -9007199254740991Maximum 9007199254740991
end_users_seeninteger
Minimum -9007199254740991Maximum 9007199254740991
end_users_overinteger
Minimum -9007199254740991Maximum 9007199254740991
scope_reachstring
One of"reachable""unreachable"
400

Bad Request

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
401

Unauthorized

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
403

Forbidden

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
500

Internal Server Error

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]

Documentation