{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paypal/json-schema/paypal-alert-input-schema.json",
  "title": "AlertInput",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paypal-alerts-api-openapi.yml#/components/schemas/AlertInput",
  "type": "object",
  "required": [
    "type",
    "code",
    "thresholds"
  ],
  "properties": {
    "type": {
      "$ref": "#/$defs/AlertType"
    },
    "code": {
      "type": "string",
      "description": "The unique code to identify the alert."
    },
    "metric_code": {
      "type": "string",
      "description": "The code of the metric associated with the alert. Required for metric-specific alert types (METRIC_CURRENT_USAGE_AMOUNT and METRIC_CURRENT_USAGE_UNITS)."
    },
    "name": {
      "type": "string",
      "description": "The name of the alert."
    },
    "thresholds": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AlertThreshold"
      },
      "description": "List of thresholds that will trigger this alert. At least one threshold is required."
    }
  },
  "$defs": {
    "AlertThreshold": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Identifier for this threshold. Used to distinguish between different thresholds."
        },
        "value": {
          "type": "string",
          "pattern": "^[0-9]+\\.?[0-9]*$",
          "description": "A value that should trigger this alert. Must be a positive numeric string that can include a decimal point."
        },
        "recurring": {
          "type": "boolean",
          "description": "When true, enables retriggering of alerts at specified intervals after the last non-recurring threshold is exceeded. For example, with non-recurring thresholds at 500 and 1000, and a recurring threshold of 200, alerts will fire at 500, 1000, then every 200 thereafter (1200, 1400, etc.). Only one recurring threshold permitted per alert."
        }
      }
    },
    "AlertType": {
      "type": "string",
      "enum": [
        "CURRENT_USAGE_AMOUNT",
        "METRIC_CURRENT_USAGE_AMOUNT",
        "METRIC_CURRENT_USAGE_UNITS",
        "LIFETIME_USAGE_AMOUNT"
      ],
      "description": "Type of alert",
      "x-enum-varnames": [
        "CURRENT_USAGE_AMOUNT",
        "METRIC_CURRENT_USAGE_AMOUNT",
        "METRIC_CURRENT_USAGE_UNITS",
        "LIFETIME_USAGE_AMOUNT"
      ],
      "x-enum-descriptions": [
        "Alert based on current usage amount",
        "Alert based on metric current usage amount",
        "Alert based on metric current usage units",
        "Alert based on lifetime usage amount"
      ]
    }
  }
}