{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paywithlocus-com/json-schema/paywithlocus-com-workspace-spend-controls-schema.json",
  "title": "WorkspaceSpendControls",
  "description": "Account-wide monthly spend controls and low-balance notification state, plus the live position in the current UTC month window. Available to Personal and enterprise accounts. Amounts are exact USD decimal strings.",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paywithlocus-com-openapi.json#/components/schemas/WorkspaceSpendControls",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "periodStart",
    "periodEnd",
    "spentUsd",
    "pendingUsd",
    "committedUsd",
    "remainingUsd",
    "monthlyLimitUsd",
    "alertThresholdUsd",
    "lowBalanceAlertUsd",
    "lowBalanceAlertSentAt",
    "hardLimitReached",
    "alert"
  ],
  "properties": {
    "periodStart": {
      "type": "string",
      "format": "date-time",
      "description": "Start of the current UTC calendar-month window."
    },
    "periodEnd": {
      "type": "string",
      "format": "date-time",
      "description": "When the window resets."
    },
    "spentUsd": {
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ],
      "description": "Captured spend in this window."
    },
    "pendingUsd": {
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ],
      "description": "Held but not yet captured (in-flight calls)."
    },
    "committedUsd": {
      "allOf": [
        {
          "$ref": "#/$defs/DecimalString"
        }
      ],
      "description": "spentUsd plus pendingUsd — the figure checked against the limit."
    },
    "remainingUsd": {
      "oneOf": [
        {
          "$ref": "#/$defs/DecimalString"
        },
        {
          "type": "null"
        }
      ],
      "description": "null when no monthly limit is set."
    },
    "monthlyLimitUsd": {
      "oneOf": [
        {
          "$ref": "#/$defs/DecimalString"
        },
        {
          "type": "null"
        }
      ],
      "description": "Hard ceiling. null means unlimited."
    },
    "alertThresholdUsd": {
      "oneOf": [
        {
          "$ref": "#/$defs/DecimalString"
        },
        {
          "type": "null"
        }
      ],
      "description": "Monthly spend email trigger. null means no alert."
    },
    "lowBalanceAlertUsd": {
      "oneOf": [
        {
          "$ref": "#/$defs/DecimalString"
        },
        {
          "type": "null"
        }
      ],
      "description": "Remaining prepaid-balance email trigger. null means no alert."
    },
    "lowBalanceAlertSentAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the current low-balance crossing was emailed. null while armed; it returns to null after the balance recovers above the threshold."
    },
    "hardLimitReached": {
      "type": "boolean",
      "description": "true once committedUsd reaches monthlyLimitUsd. Further burns are denied with TENANT_MONTHLY_SPEND_LIMIT_EXCEEDED until the window resets."
    },
    "alert": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "triggeredAt",
        "sentAt",
        "lastError"
      ],
      "properties": {
        "status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "pending",
            "sent",
            "failed",
            null
          ]
        },
        "triggeredAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "sentAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  },
  "$defs": {
    "DecimalString": {
      "type": "string",
      "pattern": "^\\d+(?:\\.\\d{1,6})?$",
      "description": "Non-negative exact decimal string with at most six fractional digits. Endpoint-specific positivity and amount limits still apply."
    }
  }
}