{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "create_service_routing",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "target": {
      "description": "Optional approved HTTPS probe alias; legacy drafts without domain route this alias's exact host",
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[a-zA-Z0-9_.-]+$"
    },
    "domain": {
      "description": "Exact domain or *.example.com (subdomains only, not the apex). Wildcards need client DNS through this router.",
      "type": "string",
      "maxLength": 253
    },
    "dnsLearningConfirmed": {
      "description": "For wildcard only: confirms clients use this router DNS, shared-IP scope and FWD adlist bypass are understood. Does not enable or intercept DNS.",
      "type": "boolean"
    },
    "precedence": {
      "description": "Explicitly allow this scoped policy before existing routing rules. Preview still binds their full configuration; FastTrack is never bypassed.",
      "type": "string",
      "enum": ["before-existing"]
    },
    "family": {
      "type": "string",
      "enum": ["ipv4", "ipv6"]
    },
    "sources": {
      "minItems": 1,
      "maxItems": 8,
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "tables": {
      "minItems": 1,
      "maxItems": 3,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "pattern": "^[a-zA-Z0-9_.-]+$"
      }
    },
    "primary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[a-zA-Z0-9_.-]+$"
    },
    "maxLatencyMs": {
      "default": 5000,
      "type": "integer",
      "minimum": 100,
      "maximum": 15000
    },
    "failuresBeforeSwitch": {
      "default": 3,
      "type": "integer",
      "minimum": 2,
      "maximum": 10
    },
    "cooldownSeconds": {
      "default": 300,
      "type": "integer",
      "minimum": 120,
      "maximum": 3600
    }
  },
  "required": [
    "name",
    "family",
    "sources",
    "tables",
    "primary",
    "maxLatencyMs",
    "failuresBeforeSwitch",
    "cooldownSeconds"
  ],
  "additionalProperties": false
}
