{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/weavz-io/json-schema/weavz-io-approval-policy-input-schema.json",
  "title": "ApprovalPolicyInput",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/weavz-io-openapi.json#/components/schemas/ApprovalPolicyInput",
  "type": "object",
  "required": [
    "name"
  ],
  "properties": {
    "workspaceId": {
      "type": "string",
      "format": "uuid",
      "description": "Optional workspace scope. Omit for an org-wide policy."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "description": {
      "type": "string",
      "maxLength": 1000
    },
    "enabled": {
      "type": "boolean",
      "default": true
    },
    "priority": {
      "type": "integer",
      "default": 100
    },
    "sources": {
      "type": "array",
      "default": [
        "rest",
        "sdk",
        "mcp_tools",
        "mcp_code"
      ],
      "items": {
        "type": "string",
        "enum": [
          "rest",
          "sdk",
          "mcp_tools",
          "mcp_code",
          "playground",
          "trigger"
        ]
      }
    },
    "mcpServerIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "workspaceIntegrationIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "integrationAliases": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "integrationNames": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "actionNames": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "connectionStrategies": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "fixed",
          "per_user",
          "per_user_with_fallback"
        ]
      }
    },
    "endUserMode": {
      "type": "string",
      "enum": [
        "any",
        "end_user_present",
        "no_end_user"
      ],
      "default": "any"
    },
    "decision": {
      "type": "string",
      "enum": [
        "require_approval",
        "notify_only",
        "block",
        "auto_approve"
      ],
      "default": "require_approval"
    },
    "riskMode": {
      "type": "string",
      "enum": [
        "always",
        "rules",
        "model_assisted"
      ],
      "default": "rules"
    },
    "rules": {
      "type": "object",
      "additionalProperties": true
    },
    "approvers": {
      "type": "array",
      "description": "Reviewer specification. Use `{ \"type\": \"webhook\", \"webhookUrl\": \"https://...\" }` to receive approval lifecycle events.",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "org_role",
              "dashboard_user",
              "end_user",
              "webhook"
            ]
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "owner",
                "admin",
                "member"
              ]
            }
          },
          "userIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Public HTTPS webhook URL for webhook approvers."
          }
        },
        "additionalProperties": true
      }
    },
    "timeoutSeconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 2592000,
      "default": 3600
    },
    "defaultOnTimeout": {
      "type": "string",
      "enum": [
        "reject",
        "expire"
      ],
      "default": "reject"
    },
    "reuseWindowSeconds": {
      "type": "integer",
      "minimum": 0,
      "maximum": 604800
    },
    "approvalAccessMode": {
      "type": "string",
      "enum": [
        "dashboard_only",
        "dashboard_and_hosted_link",
        "hosted_link_only"
      ],
      "default": "dashboard_and_hosted_link",
      "description": "Controls whether reviewers can approve through Weavz review views, hosted bearer links, or both."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true
    }
  }
}