{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/forge/json-schema/forge-forge-llmgateway-budget-update-request-schema.json",
  "title": "ForgeLLMGatewayBudgetUpdateRequest",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/forge-openapi.yaml#/components/schemas/ForgeLLMGatewayBudgetUpdateRequest",
  "allOf": [
    {
      "$ref": "#/$defs/ForgeLLMGatewayBudgetCreateRequest"
    },
    {
      "type": "object",
      "required": [
        "updatedAt"
      ],
      "properties": {
        "updatedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Last read version; stale writes return 409."
        },
        "state": {
          "type": "string",
          "enum": [
            "active",
            "disabled"
          ],
          "description": "Omission preserves the existing state."
        },
        "allowanceUsd": {
          "type": "number",
          "format": "double",
          "minimum": 0,
          "description": "Add this USD amount to the current UTC calendar-period allowance; zero removes the entire selected allowance. Requires an active USD cap and does not reset usage or bypass other budgets. Ordinary budget fields are ignored for this action. A 202 response means runtime propagation is pending."
        },
        "allowanceUserId": {
          "type": "string",
          "description": "Optional member user ID; omission targets the group or user total."
        },
        "allowanceWindowStart": {
          "type": "string",
          "format": "date-time",
          "description": "Optional expected UTC period start for a grant. A changed period returns 409 without granting allowance. Omission grants in the current period at processing time. Ignored when allowanceUsd is zero."
        }
      }
    }
  ],
  "$defs": {
    "ForgeLLMGatewayBudgetAllowance": {
      "type": "object",
      "required": [
        "amountUsd",
        "windowStart"
      ],
      "properties": {
        "amountUsd": {
          "type": "number",
          "format": "double",
          "minimum": 1e-06,
          "maximum": 1000000000000,
          "exclusiveMaximum": true
        },
        "windowStart": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "ForgeLLMGatewayBudgetCreateRequest": {
      "type": "object",
      "description": "Independent optional limit. All matching budgets apply cumulatively across providers and keys. Access assignments do not create budgets.",
      "properties": {
        "accessProfileId": {
          "type": "string",
          "description": "Optional profile filter; omission applies across access profiles."
        },
        "tokenId": {
          "type": "string"
        },
        "subjectKind": {
          "$ref": "#/$defs/ForgeLLMGatewaySubjectKind"
        },
        "subjectId": {
          "type": "string"
        },
        "budgetWindow": {
          "$ref": "#/$defs/ForgeLLMGatewayBudgetWindow"
        },
        "amountUsd": {
          "type": "number",
          "format": "double",
          "minimum": 1e-06,
          "maximum": 1000000000000,
          "exclusiveMaximum": true
        },
        "inputTokenLimit": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "outputTokenLimit": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "totalTokenLimit": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "action": {
          "type": "string",
          "enum": [
            "block"
          ]
        },
        "metadata": {
          "$ref": "#/$defs/ForgeLLMGatewayBudgetWriteMetadata"
        }
      }
    },
    "ForgeLLMGatewayBudgetWindow": {
      "type": "string",
      "enum": [
        "daily",
        "weekly",
        "monthly",
        "rolling_24h",
        "rolling_7d",
        "rolling_30d"
      ]
    },
    "ForgeLLMGatewayBudgetWriteMetadata": {
      "type": "object",
      "additionalProperties": false,
      "description": "Accepted budget settings. Unknown keys are rejected. Server-owned fields may be returned unchanged on update; use allowanceUsd to change allowances.",
      "properties": {
        "memberLimitUsd": {
          "type": "number",
          "format": "double",
          "minimum": 1e-06,
          "maximum": 1000000000000,
          "exclusiveMaximum": true
        },
        "memberLimitsUsd": {
          "type": "object",
          "additionalProperties": {
            "type": "number",
            "format": "double",
            "minimum": 1e-06,
            "maximum": 1000000000000,
            "exclusiveMaximum": true
          }
        },
        "allowance": {
          "$ref": "#/$defs/ForgeLLMGatewayBudgetAllowance"
        },
        "memberAllowances": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/ForgeLLMGatewayBudgetAllowance"
          }
        },
        "memberOfBudget": {
          "type": "string"
        },
        "memberGroupId": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "quotaResetWindow": {
          "type": "string"
        },
        "discountSource": {
          "type": "string"
        },
        "managedAccessOverride": {},
        "managedDeveloperOrganizationDefault": {},
        "softBudgetUsd": {
          "type": "number",
          "format": "double"
        },
        "softBudgetAlertEmails": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warningThresholds": {
          "type": "array",
          "items": {
            "type": "number",
            "format": "double"
          }
        },
        "negotiatedDiscountPercent": {
          "type": "number",
          "format": "double"
        },
        "costMultiplier": {
          "type": "number",
          "format": "double"
        },
        "warning_thresholds": {
          "x-go-name": "LegacyWarningThresholds",
          "type": "array",
          "items": {
            "type": "number",
            "format": "double"
          }
        },
        "negotiated_discount_percent": {
          "x-go-name": "LegacyNegotiatedDiscountPercent",
          "type": "number",
          "format": "double"
        },
        "cost_multiplier": {
          "x-go-name": "LegacyCostMultiplier",
          "type": "number",
          "format": "double"
        }
      }
    },
    "ForgeLLMGatewaySubjectKind": {
      "type": "string",
      "enum": [
        "user",
        "group",
        "app",
        "agent",
        "service_account",
        "customer_tenant"
      ]
    }
  }
}