---
title: "Update an AI Gateway budget"
method: PATCH
path: "/api/v2/budgets/{id}"
tags: ["AI Gateway"]
---

# Update an AI Gateway budget

`PATCH /api/v2/budgets/{id}`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/budgets/{id}`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `ai_gateway_config_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/budgets/:id/patch.ts> (a function with typed inputs; its response is checked against the schema)

Update a budget's mutable definition. Capacity changes apply to future accounting periods
unless `apply_to_current_period` is true.

## Path parameters

- `id` string, uuid, required

## Request body

- AiGatewayBudgetUpdateRequest: Request to update an AI Gateway budget.
  - `data` AiGatewayBudgetUpdateData, required: Data used to update an AI Gateway budget.
    - `attributes` AiGatewayBudgetUpdateAttributes, required: Mutable attributes of an AI Gateway budget.
      - `apply_to_current_period` boolean: Whether a capacity change also applies to the active accounting period. Requires capacity_microcents. Unsupported for template budgets.
      - `capacity_microcents` integer: Default capacity for future accounting periods, in microcents.
      - `enabled` boolean: Whether the budget is enabled.
      - `enforcement` 'BLOCK' | 'NOTIFY': Action taken when spend exceeds the budget.
      - `name` string: Human-readable resource name.
      - `reason` string: Optional reason recorded with an active-period capacity adjustment.
      - `track_existing` boolean: Initialize current-period spend from historical priced LLM Observability spans. Defaults to false. Unsupported for template budgets; failures can be retried with an update.
      - `warning_threshold` number, double: Fraction of capacity at which to issue a warning.
    - `id` string, uuid, required: Resource identifier. Must match the budget ID in the path.
    - `type` 'budgets', required: AI Gateway budget resource type.

## Response `200`

OK

- AiGatewayBudgetResponse: Response containing one AI Gateway budget.
  - `data` AiGatewayBudgetResource, required: AI Gateway budget resource.
    - `attributes` AiGatewayBudgetAttributes, required: AI Gateway budget configuration and metadata.
      - `capacity_microcents` integer, required: Budget capacity in microcents.
      - `created_at` string, date-time, required: Time when the resource was created.
      - `created_by` string, required: Identifier of the principal that created the resource.
      - `enabled` boolean, required: Whether the resource is enabled.
      - `enforcement` 'BLOCK' | 'NOTIFY', required: Action taken when spend exceeds the budget.
      - `monitor_id` integer, nullable, required: Datadog monitor ID provisioned for this budget. Null when monitor provisioning was skipped or failed.
      - `name` string, required: Human-readable resource name.
      - `scope_restricted` boolean, required: Whether provider or model scope metadata was withheld. Omit unchanged scope fields on an unrelated update to preserve their saved values.
      - `selector` AiGatewayBudgetSelectorEntry[], nullable: Dimension rules for a template budget. A nonempty selector creates independent counters for matched instances. Omit or pass an empty selector for a legacy fixed-scope budget.
        - `dim` string, required: Dimension to match: user_id, team_id, model, provider, or tag:<key>. Reserved metadata tag keys are rejected.
        - `per_value` boolean, required: Separate counters by the matched value when true. Otherwise, pool spend within the other separated dimensions.
        - `values` string[]: Allowed dimension values. Omit to match any value, including an absent dimension. An explicit list must contain at least one value.
      - `tags` AiGatewayBudgetTags, required: Request tags that must match for the budget to apply.
      - `team_id` string, uuid: Optional Datadog Team scope.
      - `updated_at` string, date-time, required: Time when the resource was last updated.
      - `user_id` string, uuid: User scope. Omitted when the budget is not user-scoped.
      - `warning_threshold` number, double, required: Fraction of capacity at which to issue a warning.
      - `window_policy` 'DAILY' | 'WEEKLY' | 'MONTHLY', required: UTC accounting period for a budget.
    - `id` string, uuid, required: Resource identifier.
    - `type` 'budgets', required: AI Gateway budget resource type.

## Other responses

- `400`: Bad Request
- `404`: Not Found
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
