{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/weavz-io/json-schema/weavz-io-approval-policy-schema.json",
  "title": "ApprovalPolicy",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/weavz-io-openapi.json#/components/schemas/ApprovalPolicy",
  "type": "object",
  "required": [
    "id",
    "orgId",
    "name",
    "enabled",
    "priority",
    "sources",
    "decision",
    "riskMode",
    "timeoutSeconds",
    "defaultOnTimeout",
    "approvalAccessMode",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "orgId": {
      "type": "string"
    },
    "workspaceId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "enabled": {
      "type": "boolean"
    },
    "priority": {
      "type": "integer"
    },
    "sources": {
      "type": "array",
      "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"
      ]
    },
    "decision": {
      "type": "string",
      "enum": [
        "require_approval",
        "notify_only",
        "block",
        "auto_approve"
      ]
    },
    "riskMode": {
      "type": "string",
      "enum": [
        "always",
        "rules",
        "model_assisted"
      ]
    },
    "rules": {
      "type": "object",
      "additionalProperties": true
    },
    "approvers": {
      "type": "array",
      "description": "Reviewer specification. Webhook approvers receive lifecycle events and a short-lived hosted approval URL.",
      "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"
    },
    "defaultOnTimeout": {
      "type": "string",
      "enum": [
        "reject",
        "expire"
      ]
    },
    "reuseWindowSeconds": {
      "type": [
        "integer",
        "null"
      ]
    },
    "approvalAccessMode": {
      "type": "string",
      "enum": [
        "dashboard_only",
        "dashboard_and_hosted_link",
        "hosted_link_only"
      ],
      "description": "Controls whether reviewers can approve through Weavz review views, hosted bearer links, or both."
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}