{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/orq/json-schema/orq-reset-budget-consumption-response-schema.json",
  "title": "ResetBudgetConsumptionResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/orq-budgets-api-openapi.yml#/components/schemas/ResetBudgetConsumptionResponse",
  "type": "object",
  "properties": {
    "budget": {
      "allOf": [
        {
          "$ref": "#/$defs/BudgetRestResponse"
        }
      ],
      "description": "Budget after reset. The record itself is unchanged; only counters\n were cleared."
    }
  },
  "$defs": {
    "ApiKeyBudgetScopeRestResponse": {
      "type": "object",
      "properties": {
        "apiKeyId": {
          "type": "string"
        }
      },
      "description": "Per-api-key cap. Replaces the legacy embedded `constraints.budget`\n associated with an API key."
    },
    "BudgetAlertDimension": {
      "type": "string",
      "enum": [
        "BUDGET_ALERT_DIMENSION_COST",
        "BUDGET_ALERT_DIMENSION_TOKENS"
      ]
    },
    "BudgetAlertRestResponse": {
      "required": [
        "thresholdPercent",
        "notifierIds"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Assigned by ORQ. Supply an existing id to edit that alert in place."
        },
        "thresholdPercent": {
          "type": "integer",
          "description": "Percentage of the dimension's limit at which the alert fires, 1–100.",
          "format": "uint32"
        },
        "notifierIds": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Must be workspace-scoped; project-scoped notifiers are rejected."
        },
        "dimension": {
          "description": "Defaults to COST when unset.",
          "$ref": "#/$defs/BudgetAlertDimension"
        }
      },
      "description": "Notifies every listed notifier once current-period consumption on\n `dimension` reaches `threshold_percent` of the matching limit. Each alert\n fires at most once per period, re-arming on rollover or a limit change.\n The dimension must have a limit set, or the write is rejected. A TOKENS alert is rejected."
    },
    "BudgetLimitsRestResponse": {
      "type": "object",
      "properties": {
        "period": {
          "$ref": "#/$defs/BudgetPeriod"
        },
        "amount": {
          "type": "number",
          "format": "double"
        },
        "tokenLimit": {
          "type": "number",
          "description": "Token ceiling for the budget period. Token counts are whole numbers\n and stored as integers.",
          "format": "double"
        }
      },
      "description": "BudgetLimits is the per-period spend and token ceiling. At least one\n of `amount`, `token_limit`, or RateLimit.requests_per_minute MUST be\n set on a Budget; that invariant is enforced by the handler."
    },
    "BudgetMatch": {
      "type": "object",
      "properties": {
        "cel": {
          "type": "string"
        }
      },
      "description": "CEL expression that decides whether a budget applies to a request. Available variables: `model`, `provider`, `model_id`, `api_key`, `identity`, `project`, `metadata` (map), `headers` (map, lowercase keys). An empty expression always matches. Expressions are syntax-validated at write time."
    },
    "BudgetPeriod": {
      "type": "string",
      "enum": [
        "BUDGET_PERIOD_DAILY",
        "BUDGET_PERIOD_WEEKLY",
        "BUDGET_PERIOD_MONTHLY",
        "BUDGET_PERIOD_YEARLY",
        "BUDGET_PERIOD_ONE_TIME"
      ]
    },
    "BudgetRestResponse": {
      "required": [
        "budgetId",
        "limits",
        "createdAt",
        "updatedAt"
      ],
      "type": "object",
      "properties": {
        "budgetId": {
          "type": "string"
        },
        "scope": {
          "allOf": [
            {
              "$ref": "#/$defs/BudgetScopeRestResponse"
            }
          ],
          "description": "Scope the budget was created for, used to group and filter budgets in\n the console. Not used for matching: the `match` expression decides\n which requests a budget applies to. Unset for budgets created from a\n raw CEL expression (\"custom\")."
        },
        "match": {
          "allOf": [
            {
              "$ref": "#/$defs/BudgetMatch"
            }
          ],
          "description": "The matching semantics of the budget. A budget applies to a request\n when `match.cel` evaluates to true against the request context.\n Creating a budget for a scope derives the expression for that scope\n (e.g. `provider == \"openai\"`); an empty expression matches every\n request in the workspace."
        },
        "limits": {
          "$ref": "#/$defs/BudgetLimitsRestResponse"
        },
        "rateLimit": {
          "$ref": "#/$defs/RateLimitRestResponse"
        },
        "isActive": {
          "type": "boolean",
          "default": false
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "usage": {
          "allOf": [
            {
              "$ref": "#/$defs/BudgetUsage"
            }
          ],
          "description": "Latest available consumption used for enforcement in the current\n period. This is not an exact billing ledger. Populated by read paths\n (Get / List); omitted on write responses (Create / Update / Reset)\n where it carries no signal. Absent or all-zero for a budget that\n has not been spent against in the current period."
        },
        "alerts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BudgetAlertRestResponse"
          },
          "description": "Threshold notifications. Absent when the budget has none."
        }
      },
      "description": "Budget defines limits and matching rules used to govern consumption."
    },
    "BudgetScopeRestResponse": {
      "type": "object",
      "properties": {
        "workspace": {
          "$ref": "#/$defs/WorkspaceBudgetScope"
        },
        "project": {
          "$ref": "#/$defs/ProjectBudgetScopeRestResponse"
        },
        "identity": {
          "$ref": "#/$defs/IdentityBudgetScopeRestResponse"
        },
        "apiKey": {
          "$ref": "#/$defs/ApiKeyBudgetScopeRestResponse"
        },
        "provider": {
          "$ref": "#/$defs/ProviderBudgetScope"
        },
        "model": {
          "$ref": "#/$defs/ModelBudgetScopeRestResponse"
        }
      },
      "description": "Closed oneof of workspace, project, identity, api_key, provider, or model. Exactly one variant must be set."
    },
    "BudgetUsage": {
      "type": "object",
      "properties": {
        "amount": {
          "type": "number",
          "format": "double"
        },
        "tokens": {
          "type": "number",
          "description": "Carried as a double (not int64) so it serializes as a JSON number\n rather than a quoted string, matching limits.token_limit.",
          "format": "double"
        },
        "requests": {
          "type": "integer",
          "format": "int32"
        }
      },
      "description": "BudgetUsage is the latest available current-period consumption used\n for budget enforcement, not an exact billing ledger. Each dimension is\n the consumed side of the matching limit dimension: `amount` is the\n accumulated cost in USD (vs limits.amount), `tokens` is the accumulated\n token count (vs limits.token_limit), and `requests` is the count in the\n rolling 60-second window (vs rate_limit.requests_per_minute). All three\n are explicit-presence so the triple is always emitted in full, zeros\n included — a never-spent budget serializes {amount:0, tokens:0,\n requests:0} rather than dropping its zero dimensions."
    },
    "IdentityBudgetScopeRestResponse": {
      "type": "object",
      "properties": {
        "identityExternalId": {
          "type": "string"
        }
      },
      "description": "Per-identity cap. Keyed by the contact's external identifier so the\n scope is stable across imports."
    },
    "ModelBudgetScopeRestResponse": {
      "required": [
        "modelId"
      ],
      "type": "object",
      "properties": {
        "modelId": {
          "type": "string"
        }
      },
      "description": "Per-model cap. The value is the FULL model reference as callers send\n it (\"openai/gpt-4o\", or \"workspaceKey@openai/gpt-4o\" for private\n models)."
    },
    "ProjectBudgetScopeRestResponse": {
      "type": "object",
      "properties": {
        "projectId": {
          "type": "string"
        }
      },
      "description": "Per-project cap."
    },
    "ProviderBudgetScope": {
      "type": "object",
      "properties": {
        "provider": {
          "type": "string"
        }
      },
      "description": "Per-provider cap. The value is the provider enum string (e.g.\n \"openai\", \"anthropic\") drawn from ModelIntegrationIdentifier."
    },
    "RateLimitRestResponse": {
      "type": "object",
      "properties": {
        "requestsPerMinute": {
          "type": "integer",
          "format": "int32"
        }
      },
      "description": "Per-minute request ceiling applied to the requests this budget\n matches."
    },
    "WorkspaceBudgetScope": {
      "type": "object",
      "properties": {},
      "description": "Workspace-wide ceiling. The implicit target is the caller's workspace."
    }
  }
}