{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hud-ai/json-schema/hud-ai-spend-limit-create-request-schema.json",
  "title": "SpendLimitCreateRequest",
  "description": "Create an absolute limit or a percentage alert.\n\nSet one scope ID for an API-key or membership limit, or neither for a team\nlimit. Percentage alerts set ``parent_limit_id`` and\n``threshold_percent``; their interval must match the parent and their\namount is inherited.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hud-ai-limits-api-openapi.yml#/components/schemas/SpendLimitCreateRequest",
  "properties": {
    "api_key_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Api Key Id"
    },
    "membership_id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Membership Id"
    },
    "parent_limit_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Parent Limit Id"
    },
    "threshold_percent": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 100.0,
          "exclusiveMinimum": 0.0
        },
        {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d{0,2}0*$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Threshold Percent"
    },
    "interval": {
      "$ref": "#/$defs/SpendInterval"
    },
    "amount_usd": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1000000.0,
          "exclusiveMinimum": 0.0
        },
        {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Amount Usd"
    },
    "action": {
      "$ref": "#/$defs/SpendLimitAction"
    },
    "enabled": {
      "type": "boolean",
      "title": "Enabled",
      "default": true
    }
  },
  "type": "object",
  "required": [
    "interval",
    "action"
  ],
  "$defs": {
    "SpendInterval": {
      "type": "string",
      "enum": [
        "week",
        "month"
      ],
      "title": "SpendInterval"
    },
    "SpendLimitAction": {
      "type": "string",
      "enum": [
        "alert",
        "block"
      ],
      "title": "SpendLimitAction"
    }
  }
}