{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/secureai-one/json-schema/secureai-one-policy-schema.json",
  "title": "Policy",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/secureai-one-openapi.json#/components/schemas/Policy",
  "type": "object",
  "properties": {
    "version": {
      "type": "integer",
      "enum": [
        1
      ]
    },
    "fallback": {
      "type": "string",
      "enum": [
        "allow",
        "redact",
        "approve",
        "block"
      ],
      "description": "What happens to a kind no rule mentions."
    },
    "rules": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Rule"
      },
      "maxItems": 200
    },
    "denyTools": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tools that may not be called at all, whatever is inside them."
    },
    "allow": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 500,
      "description": "Literal values that are never sensitive here. A leading \"@\" exempts a whole domain. These are stored, unlike anything in the audit trail."
    },
    "gatewayAllow": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 200,
      "description": "Hosts the gateway may forward to. Empty or absent means any public host. A leading \".\" matches a domain and its subdomains. Private-address rules still apply and cannot be opened up from here."
    },
    "webhook": {
      "type": "object",
      "description": "Where to POST when an action is refused. The payload is the audit record, which holds kinds and locations and never values.",
      "properties": {
        "url": {
          "type": "string",
          "description": "https only. Private and link-local addresses are refused, as everywhere else."
        },
        "on": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "allow",
              "redact",
              "block"
            ]
          },
          "description": "Which decisions to send. Defaults to blocks only — a notification on every allowed action is one nobody reads."
        },
        "secret": {
          "type": "string",
          "maxLength": 200,
          "description": "When set, each delivery carries X-Secure-AI-Signature: sha256=<hmac of the body>."
        }
      },
      "required": [
        "url"
      ]
    },
    "approvalTtlSeconds": {
      "type": "integer",
      "minimum": 30,
      "maximum": 86400,
      "description": "How long a held action waits before it is denied. Expiry is a denial and never a release — an action somebody wanted reviewed must not proceed because nobody had time to review it."
    }
  },
  "required": [
    "version",
    "fallback",
    "rules"
  ],
  "$defs": {
    "Rule": {
      "type": "object",
      "description": "One line of policy. When two rules match the same finding, the later one wins.",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "secret",
            "card",
            "iban",
            "ssn",
            "govid",
            "email",
            "phone",
            "address",
            "postcode",
            "name",
            "host"
          ]
        },
        "decision": {
          "type": "string",
          "enum": [
            "allow",
            "redact",
            "approve",
            "block"
          ]
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Only these tools. Exact, or a single trailing \"*\". Absent means all."
        },
        "direction": {
          "type": "string",
          "enum": [
            "outbound",
            "inbound"
          ],
          "description": "Absent means both."
        }
      },
      "required": [
        "kind",
        "decision"
      ]
    }
  }
}