{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Integration Plugin Schema",
  "description": "Schema for custom integration plugins in Loki Mode",
  "type": "object",
  "required": ["type", "name", "description", "webhook_url", "events"],
  "properties": {
    "type": {
      "const": "integration"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{2,49}$",
      "description": "Unique integration name (lowercase, 3-50 chars, alphanumeric and hyphens)"
    },
    "description": {
      "type": "string",
      "maxLength": 500,
      "description": "Human-readable description of the integration"
    },
    "webhook_url": {
      "type": "string",
      "format": "uri",
      "description": "URL to POST event payloads to"
    },
    "events": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "description": "List of event types to subscribe to"
    },
    "payload_template": {
      "type": "string",
      "maxLength": 5000,
      "description": "JSON template for the webhook payload (supports {{event.*}} variables)"
    },
    "headers": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Additional HTTP headers to send with webhook requests"
    },
    "timeout_ms": {
      "type": "integer",
      "minimum": 1000,
      "maximum": 30000,
      "default": 5000,
      "description": "HTTP request timeout in milliseconds"
    },
    "retry_count": {
      "type": "integer",
      "minimum": 0,
      "maximum": 3,
      "default": 1,
      "description": "Number of retry attempts on failure"
    }
  },
  "additionalProperties": false
}
