{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vulnify-io/json-schema/vulnify-io-policy-record-schema.json",
  "title": "PolicyRecord",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vulnify-io-openapi.json#/components/schemas/PolicyRecord",
  "allOf": [
    {
      "$ref": "#/$defs/PolicySpec"
    },
    {
      "type": "object",
      "required": [
        "id",
        "updatedAt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  ],
  "$defs": {
    "PolicyCondition": {
      "type": "object",
      "additionalProperties": false,
      "description": "Every field that is set must match. minRecords means recordsAffected is greater than or equal to the value. maxRecords means recordsAffected is less than or equal to the value. Groups may nest up to 32 levels, with at most 20000 conditions in one group. minRecords and maxRecords are integers from 0 through 9007199254740991. agentIds holds at most 8000 ids. allOf matches when every nested condition matches. anyOf matches when at least one does. An empty allOf matches. An empty anyOf does not. dlpTypes and lgpdCategories are accepted here and are not part of the policies-as-code YAML schema.",
      "properties": {
        "action": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Event action (READ_DATA, WRITE_DATA, DELETE_DATA, EXPORT_DATA, SEND_EMAIL) or an action family. Matched against the event action and its family."
        },
        "destination": {
          "type": "string",
          "enum": [
            "EXTERNAL",
            "INTERNAL"
          ],
          "description": "EXTERNAL matches an external destination. INTERNAL matches an internal one."
        },
        "destinationContains": {
          "type": "string",
          "maxLength": 100,
          "description": "Case-insensitive substring of the destination."
        },
        "containsSensitiveData": {
          "type": "boolean"
        },
        "minRecords": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "maxRecords": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "minRiskScore": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "outsideBusinessHours": {
          "type": "boolean",
          "description": "Monday to Friday 09:00-18:00 in the organization time zone, inverted."
        },
        "agentIds": {
          "type": "array",
          "maxItems": 8000,
          "items": {
            "type": "string"
          }
        },
        "dlpTypes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "CPF",
              "CNPJ",
              "RG",
              "CNH",
              "PIX_KEY",
              "PHONE_BR",
              "CEP",
              "CREDIT_CARD",
              "EMAIL",
              "HEALTH_DATA",
              "API_KEY",
              "PRIVATE_KEY"
            ]
          }
        },
        "lgpdCategories": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "IDENTIFICATION",
              "CONTACT",
              "LOCATION",
              "FINANCIAL",
              "HEALTH",
              "COMPANY",
              "CREDENTIALS"
            ]
          }
        },
        "allOf": {
          "type": "array",
          "maxItems": 20000,
          "items": {
            "$ref": "#/$defs/PolicyCondition"
          }
        },
        "anyOf": {
          "type": "array",
          "maxItems": 20000,
          "items": {
            "$ref": "#/$defs/PolicyCondition"
          }
        }
      }
    },
    "PolicySpec": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "action",
        "decision"
      ],
      "description": "One policy. name is unique per organization. action is the action family (for example EXPORT), not an event action such as EXPORT_DATA. Omitted enabled defaults to true. Omitted mode defaults to ENFORCE. Omitted resource, null and ANY match every classification.",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "description": {
          "type": "string",
          "maxLength": 500
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "action": {
          "type": "string",
          "enum": [
            "ANY",
            "READ",
            "WRITE",
            "DELETE",
            "EXPORT"
          ]
        },
        "resource": {
          "description": "Resource classification. ANY and null match every classification.",
          "nullable": true,
          "enum": [
            "ANY",
            "PUBLIC",
            "INTERNAL",
            "SENSITIVE",
            "CUSTOMER_PII",
            "FINANCIAL",
            "EMPLOYEE",
            null
          ]
        },
        "condition": {
          "$ref": "#/$defs/PolicyCondition"
        },
        "decision": {
          "type": "string",
          "enum": [
            "ALLOW",
            "REVIEW",
            "BLOCK"
          ]
        },
        "mode": {
          "type": "string",
          "enum": [
            "ENFORCE",
            "MONITOR"
          ],
          "default": "ENFORCE"
        },
        "approverRoles": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "enum": [
              "OWNER",
              "ADMIN",
              "MEMBER"
            ]
          },
          "description": "Roles that may approve a REVIEW raised by this policy. Empty means owners and admins."
        }
      }
    }
  }
}