{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://optinrouter.ai/docs/schemas/policy.schema.json",
  "title": "OptinRouter policy preview contract",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "version": {
      "const": "2026-10-19-preview"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "mode": {
      "const": "enterprise_private"
    },
    "allowed_locations": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "enum": [
          "managed",
          "customer_server",
          "end_device"
        ]
      }
    },
    "routing": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "models": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "^[a-zA-Z0-9_.@:/-]+$"
          }
        },
        "regions": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "require_verified_region": {
          "const": true
        }
      },
      "required": [
        "models",
        "regions",
        "require_verified_region"
      ]
    },
    "retention": {
      "const": "no_content"
    },
    "data_exchange": {
      "const": false
    },
    "input": {
      "type": "array",
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "enum": [
              "semantic_filter",
              "redact",
              "grammar",
              "context_lookup",
              "usage_check"
            ]
          },
          "ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "^[a-zA-Z0-9_.@:/-]+$"
          },
          "required": {
            "type": "boolean"
          }
        },
        "required": [
          "kind",
          "ref",
          "required"
        ]
      }
    },
    "output": {
      "type": "array",
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "enum": [
              "semantic_filter",
              "redact",
              "grammar",
              "context_lookup",
              "usage_check"
            ]
          },
          "ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "^[a-zA-Z0-9_.@:/-]+$"
          },
          "required": {
            "type": "boolean"
          }
        },
        "required": [
          "kind",
          "ref",
          "required"
        ]
      }
    },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "deadline_ms": {
          "type": "integer",
          "minimum": 100,
          "maximum": 120000
        },
        "max_parallel_actions": {
          "type": "integer",
          "minimum": 0,
          "maximum": 8
        },
        "max_repair_attempts": {
          "type": "integer",
          "minimum": 0,
          "maximum": 2
        },
        "max_input_tokens": {
          "type": "integer",
          "minimum": 256,
          "maximum": 1000000
        },
        "max_cost_usd": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 5
        }
      },
      "required": [
        "deadline_ms",
        "max_parallel_actions",
        "max_repair_attempts"
      ]
    },
    "failure_mode": {
      "const": "block"
    },
    "delivery": {
      "enum": [
        "buffered",
        "validated_stream_units"
      ]
    }
  },
  "required": [
    "version",
    "name",
    "mode",
    "allowed_locations",
    "routing",
    "retention",
    "data_exchange",
    "input",
    "output",
    "limits",
    "failure_mode",
    "delivery"
  ]
}
