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.
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.
Try this endpoint
app.langwatch.ai
API key · X-Auth-Token
Kept in this tab. Cleared when you reload.
Body (application/json)
This sends a live request to app.langwatch.ai.
Request and response examples
request.py
import osimport requestsorigin = "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())const url = "https://app.langwatch.ai/api/gateway/v1/budgets/<id>";const response = await fetch(url, { method: "PATCH", headers: { "X-Auth-Token": process.env.LANGWATCH_API_KEY!, },});const data = await response.json();curl --request PATCH \ --url 'https://app.langwatch.ai/api/gateway/v1/budgets/<id>' \ --header "X-Auth-Token: $LANGWATCH_API_KEY"Call the LangWatch API from this project: Update budget.Request: PATCH https://app.langwatch.ai/api/gateway/v1/budgets/<id>Reference: https://langwatch.ai/docs/api-reference/gateway-budgets/update-budget.mdAuthentication: send the X-Auth-Token header, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.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" }}Bad Request
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Unauthorized
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Forbidden
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Internal Server Error
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Path parameters
idstringrequiredAt least 1 character
Request body
application/json
namestringAt least 1 characterUp to 128 characters
descriptionstring | nulllimit_usdnumber | stringon_breachstringOne of
"block""warn"timezonestring | nullexternal_idstring | nullmetadataobjectResponses
200Success
application/json
budgetobjectrequired400Bad Request
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstringOne of
"customer""platform""provider""presumed_platform"reasonsany[]401Unauthorized
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstringOne of
"customer""platform""provider""presumed_platform"reasonsany[]403Forbidden
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstringOne of
"customer""platform""provider""presumed_platform"reasonsany[]500Internal Server Error
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstringOne of
"customer""platform""provider""presumed_platform"reasonsany[]