{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/actionbox-cloud/json-schema/actionbox-cloud-managed-policy-create-schema.json",
  "title": "ManagedPolicyCreate",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/actionbox-cloud-workspaces-api-openapi.yml#/components/schemas/ManagedPolicyCreate",
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 120,
      "minLength": 1,
      "title": "Name"
    },
    "group_id": {
      "type": "string",
      "maxLength": 64,
      "minLength": 1,
      "title": "Group Id"
    },
    "rule": {
      "$ref": "#/$defs/ApprovalPolicy"
    },
    "exclude_source_owner": {
      "type": "boolean",
      "title": "Exclude Source Owner",
      "default": false
    },
    "routes": {
      "items": {
        "$ref": "#/$defs/ManagedPolicyRoute"
      },
      "type": "array",
      "maxItems": 8,
      "title": "Routes"
    },
    "stages": {
      "items": {
        "$ref": "#/$defs/ManagedPolicyStage"
      },
      "type": "array",
      "maxItems": 2,
      "title": "Stages"
    }
  },
  "type": "object",
  "required": [
    "name",
    "group_id",
    "rule"
  ],
  "$defs": {
    "ApprovalPolicy": {
      "properties": {
        "schema_version": {
          "type": "integer",
          "const": 1,
          "title": "Schema Version",
          "default": 1
        },
        "mode": {
          "type": "string",
          "enum": [
            "any",
            "all",
            "quorum"
          ],
          "title": "Mode"
        },
        "required_approvals": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 15.0,
              "minimum": 1.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Required Approvals"
        },
        "approval_option_id": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 80,
              "minLength": 1
            },
            {
              "type": "null"
            }
          ],
          "title": "Approval Option Id"
        },
        "rejection_option_id": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 80,
              "minLength": 1
            },
            {
              "type": "null"
            }
          ],
          "title": "Rejection Option Id"
        },
        "allow_source_override": {
          "type": "boolean",
          "title": "Allow Source Override",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "mode"
      ],
      "title": "ApprovalPolicy"
    },
    "ManagedPolicyRoute": {
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 80,
          "minLength": 1,
          "pattern": "^[A-Za-z][A-Za-z0-9_.-]*$",
          "title": "Name"
        },
        "match": {
          "$ref": "#/$defs/ManagedPolicyRouteMatch"
        },
        "group_id": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "title": "Group Id"
        },
        "rule": {
          "$ref": "#/$defs/ApprovalPolicy"
        },
        "exclude_source_owner": {
          "type": "boolean",
          "title": "Exclude Source Owner",
          "default": false
        },
        "stages": {
          "items": {
            "$ref": "#/$defs/ManagedPolicyStage"
          },
          "type": "array",
          "maxItems": 2,
          "title": "Stages"
        }
      },
      "type": "object",
      "required": [
        "name",
        "match",
        "group_id",
        "rule"
      ],
      "title": "ManagedPolicyRoute"
    },
    "ManagedPolicyRouteMatch": {
      "properties": {
        "decision_class": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 120,
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_.-]+$"
            },
            {
              "type": "null"
            }
          ],
          "title": "Decision Class"
        },
        "priority": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "low",
                "normal",
                "high",
                "urgent"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Priority"
        }
      },
      "type": "object",
      "title": "ManagedPolicyRouteMatch"
    },
    "ManagedPolicyStage": {
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 80,
          "minLength": 1,
          "pattern": "^[A-Za-z][A-Za-z0-9_.-]*$",
          "title": "Name"
        },
        "group_id": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "title": "Group Id"
        },
        "rule": {
          "$ref": "#/$defs/ApprovalPolicy"
        },
        "exclude_source_owner": {
          "type": "boolean",
          "title": "Exclude Source Owner",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "name",
        "group_id",
        "rule"
      ],
      "title": "ManagedPolicyStage"
    }
  }
}