{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mailbuttons-com/json-schema/mailbuttons-com-mail-policy-schema.json",
  "title": "MailPolicy",
  "description": "camelCase on the wire. On PUT, `senders`/`contentGuards`/`blocklist`\ndefault to empty and `mode` defaults to `live` when omitted; the GET/PUT\nresponse always includes all of them (`blocklist` omitted when empty).\n",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mailbuttons-com-openapi.json#/components/schemas/MailPolicy",
  "properties": {
    "auditLog": {
      "$ref": "#/$defs/AuditConfig"
    },
    "blocklist": {
      "description": "Recipient addresses/bare domains this mailbox may never send to. Omitted when empty.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "contentGuards": {
      "items": {
        "$ref": "#/$defs/ContentGuard"
      },
      "type": "array"
    },
    "defaultAction": {
      "enum": [
        "bounce",
        "drop"
      ],
      "type": "string"
    },
    "mode": {
      "enum": [
        "live",
        "supervised",
        "shadow"
      ],
      "type": "string"
    },
    "senders": {
      "items": {
        "$ref": "#/$defs/SenderRule"
      },
      "type": "array"
    }
  },
  "required": [
    "defaultAction",
    "senders",
    "contentGuards",
    "mode",
    "auditLog"
  ],
  "type": "object",
  "$defs": {
    "AuditConfig": {
      "properties": {
        "includeBodyHash": {
          "type": "boolean"
        },
        "retentionDays": {
          "format": "int32",
          "type": "integer"
        }
      },
      "required": [
        "retentionDays",
        "includeBodyHash"
      ],
      "type": "object"
    },
    "ContentGuard": {
      "properties": {
        "reason": {
          "type": "string"
        },
        "reject": {
          "description": "Regex source (Rust `regex` crate flavour); compiled at PUT time.",
          "type": "string"
        }
      },
      "required": [
        "reject",
        "reason"
      ],
      "type": "object"
    },
    "RateLimit": {
      "properties": {
        "perDay": {
          "format": "int32",
          "type": "integer"
        },
        "perHour": {
          "format": "int32",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "SenderMatch": {
      "properties": {
        "address": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        },
        "requireDkim": {
          "type": "boolean"
        },
        "requireSpf": {
          "type": "boolean"
        }
      },
      "required": [
        "requireDkim",
        "requireSpf"
      ],
      "type": "object"
    },
    "SenderRule": {
      "properties": {
        "allowedHosts": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "capabilities": {
          "description": "Opaque capability strings; unknown values warn but don't reject at PUT time.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "match": {
          "$ref": "#/$defs/SenderMatch"
        },
        "passive": {
          "description": "When true, matching mail is accepted and audited but never invokes the agent.",
          "type": "boolean"
        },
        "rateLimit": {
          "$ref": "#/$defs/RateLimit"
        },
        "tokenBudget": {
          "$ref": "#/$defs/TokenBudget"
        }
      },
      "required": [
        "match",
        "capabilities",
        "passive"
      ],
      "type": "object"
    },
    "TokenBudget": {
      "properties": {
        "perDay": {
          "format": "int32",
          "type": "integer"
        },
        "perThread": {
          "format": "int32",
          "type": "integer"
        }
      },
      "type": "object"
    }
  }
}