{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.acriva.de/schemas/workflow.schema.json",
  "title": "Acriva workflow.yaml",
  "description": "One workflow as a file, format 1 (ADR-0132). Generated from the format's records; don't edit by hand.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "format": {
      "const": 1
    },
    "schemaVersion": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9
    },
    "sdk": {
      "type": "string"
    },
    "key": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "template": {
      "type": "string",
      "enum": [
        "invoiceApproval",
        "contractReview",
        "mailDistribution",
        "hrFileIntake",
        "custom"
      ]
    },
    "trigger": {
      "type": "object",
      "properties": {
        "documentType": {
          "type": [
            "string",
            "null"
          ]
        },
        "deadline": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "stage": {
              "type": "string",
              "enum": [
                "reminder",
                "due"
              ]
            },
            "kind": {
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "end",
                "notice",
                "dateField",
                "obligation",
                "followUp",
                null
              ]
            },
            "ruleKey": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "stage"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "invoice": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "suggestAllocation": {
              "type": "boolean"
            },
            "collectiveApproval": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "cap": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              },
              "required": [
                "enabled"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "suggestAllocation",
            "collectiveApproval"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "date",
              "money",
              "enumeration"
            ]
          },
          "labelDe": {
            "type": "string"
          },
          "labelEn": {
            "type": "string"
          },
          "documentTypes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "options": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "labelDe": {
                  "type": "string"
                },
                "labelEn": {
                  "type": "string"
                }
              },
              "required": [
                "key",
                "labelDe",
                "labelEn"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "key",
          "kind",
          "labelDe",
          "labelEn",
          "documentTypes"
        ],
        "additionalProperties": false
      }
    },
    "start": {
      "type": "string"
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "kind"
        ],
        "anyOf": [
          {
            "properties": {
              "kind": {
                "const": "humanTask"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "taskKind": {
                "type": "string",
                "enum": [
                  "approve",
                  "review",
                  "acknowledge",
                  "fix",
                  "capture",
                  "signatureFieldReview"
                ]
              },
              "assignees": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "when": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "required": [
                        "kind"
                      ],
                      "anyOf": [
                        {
                          "properties": {
                            "kind": {
                              "const": "compare"
                            },
                            "field": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "value": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "lastTaskOutcome",
                                "documentTags",
                                "documentFiles",
                                "invoiceCostCenter",
                                null
                              ]
                            },
                            "output": {
                              "type": [
                                "object",
                                "null"
                              ],
                              "properties": {
                                "step": {
                                  "type": "string"
                                },
                                "key": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "step",
                                "key"
                              ],
                              "additionalProperties": false
                            },
                            "operator": {
                              "type": "string",
                              "enum": [
                                "equalTo",
                                "notEqualTo",
                                "lessThan",
                                "lessOrEqual",
                                "greaterThan",
                                "greaterOrEqual",
                                "isEmpty",
                                "isOneOf"
                              ]
                            },
                            "constants": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "files": {
                              "type": [
                                "array",
                                "null"
                              ],
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  },
                                  "number": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "number"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "operator",
                            "constants"
                          ],
                          "additionalProperties": false,
                          "if": {
                            "properties": {
                              "value": {
                                "const": "documentFiles"
                              }
                            },
                            "required": [
                              "value"
                            ]
                          },
                          "then": {
                            "properties": {
                              "constants": {
                                "maxItems": 0
                              }
                            }
                          },
                          "else": {
                            "properties": {
                              "files": {
                                "type": "null"
                              }
                            }
                          }
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "and"
                            },
                            "conditions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "kind"
                                ],
                                "anyOf": [
                                  {
                                    "properties": {
                                      "kind": {
                                        "const": "compare"
                                      },
                                      "field": {
                                        "type": [
                                          "string",
                                          "null"
                                        ]
                                      },
                                      "value": {
                                        "type": [
                                          "string",
                                          "null"
                                        ],
                                        "enum": [
                                          "lastTaskOutcome",
                                          "documentTags",
                                          "documentFiles",
                                          "invoiceCostCenter",
                                          null
                                        ]
                                      },
                                      "output": {
                                        "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/output"
                                      },
                                      "operator": {
                                        "type": "string",
                                        "enum": [
                                          "equalTo",
                                          "notEqualTo",
                                          "lessThan",
                                          "lessOrEqual",
                                          "greaterThan",
                                          "greaterOrEqual",
                                          "isEmpty",
                                          "isOneOf"
                                        ]
                                      },
                                      "constants": {
                                        "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/constants"
                                      },
                                      "files": {
                                        "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/files"
                                      }
                                    },
                                    "required": [
                                      "operator",
                                      "constants"
                                    ],
                                    "additionalProperties": false,
                                    "if": {
                                      "properties": {
                                        "value": {
                                          "const": "documentFiles"
                                        }
                                      },
                                      "required": [
                                        "value"
                                      ]
                                    },
                                    "then": {
                                      "properties": {
                                        "constants": {
                                          "maxItems": 0
                                        }
                                      }
                                    },
                                    "else": {
                                      "properties": {
                                        "files": {
                                          "type": "null"
                                        }
                                      }
                                    }
                                  },
                                  {
                                    "properties": {
                                      "kind": {
                                        "const": "and"
                                      },
                                      "conditions": {
                                        "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions"
                                      }
                                    },
                                    "required": [
                                      "conditions"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "properties": {
                                      "kind": {
                                        "const": "or"
                                      },
                                      "conditions": {
                                        "type": "array",
                                        "items": {
                                          "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions/items"
                                        }
                                      }
                                    },
                                    "required": [
                                      "conditions"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "properties": {
                                      "kind": {
                                        "const": "tableLookup"
                                      },
                                      "table": {
                                        "type": "string"
                                      },
                                      "keyField": {
                                        "type": "string"
                                      },
                                      "column": {
                                        "type": [
                                          "string",
                                          "null"
                                        ]
                                      },
                                      "operator": {
                                        "type": [
                                          "string",
                                          "null"
                                        ],
                                        "enum": [
                                          "equalTo",
                                          "notEqualTo",
                                          "lessThan",
                                          "lessOrEqual",
                                          "greaterThan",
                                          "greaterOrEqual",
                                          "isEmpty",
                                          "isOneOf",
                                          null
                                        ]
                                      },
                                      "constants": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      }
                                    },
                                    "required": [
                                      "table",
                                      "keyField",
                                      "constants"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            }
                          },
                          "required": [
                            "conditions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "or"
                            },
                            "conditions": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions/items/anyOf/2/properties/conditions"
                            }
                          },
                          "required": [
                            "conditions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "tableLookup"
                            },
                            "table": {
                              "type": "string"
                            },
                            "keyField": {
                              "type": "string"
                            },
                            "column": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "operator": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "equalTo",
                                "notEqualTo",
                                "lessThan",
                                "lessOrEqual",
                                "greaterThan",
                                "greaterOrEqual",
                                "isEmpty",
                                "isOneOf",
                                null
                              ]
                            },
                            "constants": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions/items/anyOf/3/properties/constants"
                            }
                          },
                          "required": [
                            "table",
                            "keyField",
                            "constants"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "assignee": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "member",
                            "role",
                            "requester",
                            "costCenterResponsible",
                            "approvalLimit",
                            "deadlineOwner"
                          ]
                        },
                        "member": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "role": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "table": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "kind"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "assignee"
                  ],
                  "additionalProperties": false
                }
              },
              "fallback": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "member",
                      "role",
                      "requester",
                      "costCenterResponsible",
                      "approvalLimit",
                      "deadlineOwner"
                    ]
                  },
                  "member": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "role": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "table": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              "options": {
                "type": "object",
                "properties": {
                  "remindAfterWorkingDays": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "escalateAfterWorkingDays": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "escalationTarget": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "member",
                          "role",
                          "requester",
                          "costCenterResponsible",
                          "approvalLimit",
                          "deadlineOwner"
                        ]
                      },
                      "member": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "role": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "table": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "kind"
                    ],
                    "additionalProperties": false
                  },
                  "excludeRequester": {
                    "type": "boolean"
                  },
                  "excludeActorsOfSteps": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "pickFile": {
                    "type": "boolean"
                  },
                  "deadline": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "value": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "step": {
                            "type": "string"
                          },
                          "key": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "step",
                          "key"
                        ],
                        "additionalProperties": false,
                        "default": null
                      },
                      "dateField": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "default": null
                      },
                      "remindBeforeWorkingDays": {
                        "type": [
                          "integer",
                          "null"
                        ],
                        "default": null
                      },
                      "escalateBeforeWorkingDays": {
                        "type": [
                          "integer",
                          "null"
                        ],
                        "default": null
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": [
                  "excludeRequester",
                  "excludeActorsOfSteps",
                  "pickFile"
                ],
                "additionalProperties": false
              },
              "next": {
                "type": "string"
              },
              "onRejected": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "requiredFields": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "requireComment": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "fields",
                  "requireComment"
                ],
                "additionalProperties": false
              },
              "parallelApproval": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "all",
                      "any",
                      "quorum"
                    ]
                  },
                  "approvers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "member",
                            "role",
                            "requester",
                            "costCenterResponsible",
                            "approvalLimit",
                            "deadlineOwner"
                          ]
                        },
                        "member": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "role": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "table": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "kind"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "quorum": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "mode",
                  "approvers"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "taskKind",
              "assignees",
              "fallback",
              "options",
              "next"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "condition"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "branches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "when": {
                      "type": "object",
                      "required": [
                        "kind"
                      ],
                      "anyOf": [
                        {
                          "properties": {
                            "kind": {
                              "const": "compare"
                            },
                            "field": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "value": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "lastTaskOutcome",
                                "documentTags",
                                "documentFiles",
                                "invoiceCostCenter",
                                null
                              ]
                            },
                            "output": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/output"
                            },
                            "operator": {
                              "type": "string",
                              "enum": [
                                "equalTo",
                                "notEqualTo",
                                "lessThan",
                                "lessOrEqual",
                                "greaterThan",
                                "greaterOrEqual",
                                "isEmpty",
                                "isOneOf"
                              ]
                            },
                            "constants": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/constants"
                            },
                            "files": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/0/properties/files"
                            }
                          },
                          "required": [
                            "operator",
                            "constants"
                          ],
                          "additionalProperties": false,
                          "if": {
                            "properties": {
                              "value": {
                                "const": "documentFiles"
                              }
                            },
                            "required": [
                              "value"
                            ]
                          },
                          "then": {
                            "properties": {
                              "constants": {
                                "maxItems": 0
                              }
                            }
                          },
                          "else": {
                            "properties": {
                              "files": {
                                "type": "null"
                              }
                            }
                          }
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "and"
                            },
                            "conditions": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions"
                            }
                          },
                          "required": [
                            "conditions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "or"
                            },
                            "conditions": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions/items/anyOf/2/properties/conditions"
                            }
                          },
                          "required": [
                            "conditions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "properties": {
                            "kind": {
                              "const": "tableLookup"
                            },
                            "table": {
                              "type": "string"
                            },
                            "keyField": {
                              "type": "string"
                            },
                            "column": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "operator": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "equalTo",
                                "notEqualTo",
                                "lessThan",
                                "lessOrEqual",
                                "greaterThan",
                                "greaterOrEqual",
                                "isEmpty",
                                "isOneOf",
                                null
                              ]
                            },
                            "constants": {
                              "$ref": "#/properties/steps/items/anyOf/0/properties/assignees/items/properties/when/anyOf/1/properties/conditions/items/anyOf/3/properties/constants"
                            }
                          },
                          "required": [
                            "table",
                            "keyField",
                            "constants"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "when",
                    "next"
                  ],
                  "additionalProperties": false
                }
              },
              "default": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "branches",
              "default"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "timer"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "next": {
                "type": "string"
              },
              "days": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "dateField": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "daysBefore": {
                "type": "integer"
              }
            },
            "required": [
              "name",
              "next",
              "daysBefore"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "notification"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "next": {
                "type": "string"
              },
              "recipients": {
                "type": "array",
                "items": {
                  "$ref": "#/properties/steps/items/anyOf/0/properties/parallelApproval/properties/approvers/items"
                }
              },
              "notice": {
                "type": "string",
                "enum": [
                  "forInformation"
                ]
              }
            },
            "required": [
              "name",
              "next",
              "recipients",
              "notice"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "filing"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "next": {
                "type": "string"
              },
              "file": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "number": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "number"
                ],
                "additionalProperties": false
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "byField": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "fileType": {
                    "type": "string"
                  },
                  "keyField": {
                    "type": "string"
                  },
                  "documentField": {
                    "type": "string"
                  },
                  "create": {
                    "type": "boolean"
                  },
                  "nameField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "fileType",
                  "keyField",
                  "documentField",
                  "create"
                ],
                "additionalProperties": false
              },
              "onCreated": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "onNoFile": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "next",
              "tags"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "aiAction"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "next": {
                "type": "string"
              },
              "action": {
                "type": "string",
                "enum": [
                  "suggestApprover",
                  "checkDuplicate",
                  "summarize",
                  "checkPlausibility",
                  "classifyAgain",
                  "extractAgain"
                ]
              },
              "allowConfidential": {
                "type": "boolean"
              },
              "onSkipped": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "deviationPercent": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "next",
              "action"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "end"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "running",
                  "approved",
                  "rejected",
                  "completed",
                  "cancelled",
                  "failed"
                ]
              }
            },
            "required": [
              "name",
              "outcome"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "script"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "script": {
                "type": "string"
              },
              "hook": {
                "type": "string",
                "enum": [
                  "onDocumentArrived",
                  "beforeApproval",
                  "onApproved",
                  "onRejected",
                  "onTimer"
                ]
              },
              "inputs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "field",
                        "source",
                        "table"
                      ]
                    },
                    "key": {
                      "type": "string"
                    },
                    "type": {
                      "default": null,
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "text",
                        "number",
                        "money",
                        "date",
                        "boolean",
                        "enumeration",
                        "reference",
                        null
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "key"
                  ],
                  "additionalProperties": false
                }
              },
              "returns": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "number",
                        "money",
                        "date",
                        "boolean",
                        "enumeration",
                        "reference"
                      ]
                    },
                    "values": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "key",
                    "type",
                    "values"
                  ],
                  "additionalProperties": false
                }
              },
              "branch": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "exits": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "value": {
                      "type": "string"
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "value",
                    "next"
                  ],
                  "additionalProperties": false
                }
              },
              "next": {
                "type": "string"
              },
              "onFailure": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "script",
              "hook",
              "inputs",
              "returns",
              "exits",
              "next"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "setField"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "assignments": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "constant",
                        "field",
                        "datePlusDays",
                        "sum",
                        "difference",
                        "tableLookup"
                      ]
                    },
                    "value": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "default": null
                    },
                    "operands": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "type": "string"
                      },
                      "default": null
                    },
                    "days": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "default": null
                    },
                    "lookup": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "table": {
                          "type": "string"
                        },
                        "keyField": {
                          "type": "string"
                        },
                        "column": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "table",
                        "keyField",
                        "column"
                      ],
                      "additionalProperties": false,
                      "default": null
                    }
                  },
                  "required": [
                    "field",
                    "source"
                  ],
                  "additionalProperties": false
                }
              },
              "next": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "assignments",
              "next"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "aiCustom"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "instruction": {
                "type": "string"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "readText": {
                "type": "boolean"
              },
              "answer": {
                "type": "string",
                "enum": [
                  "yesNo",
                  "choice",
                  "number",
                  "text"
                ]
              },
              "choices": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "next": {
                "type": "string"
              },
              "suggestField": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "allowConfidential": {
                "type": "boolean"
              },
              "onSkipped": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "instruction",
              "fields",
              "readText",
              "answer",
              "choices",
              "next"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "wait"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "waitFor": {
                "type": "string",
                "enum": [
                  "fieldSet",
                  "document",
                  "startedWorkflow"
                ]
              },
              "field": {
                "type": "string"
              },
              "documentType": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "otherField": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "timeoutDays": {
                "type": "integer"
              },
              "next": {
                "type": "string"
              },
              "onTimeout": {
                "type": "string"
              },
              "startStep": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "waitFor",
              "field",
              "timeoutDays",
              "next",
              "onTimeout"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "startWorkflow"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "workflow": {
                "type": "string",
                "description": "The package key of the workflow to start, as its folder under workflows/ is named: a workflow of this package or one the workspace has."
              },
              "next": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "workflow",
              "next"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "externalEmail"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "template": {
                "type": "string"
              },
              "recipient": {
                "type": "string",
                "enum": [
                  "vendor",
                  "field",
                  "fixed"
                ]
              },
              "language": {
                "type": "string"
              },
              "recipientField": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "allowConfidential": {
                "type": "boolean"
              },
              "allowAiRecipient": {
                "type": "boolean"
              },
              "next": {
                "type": "string"
              },
              "onSkipped": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "template",
              "recipient",
              "language",
              "next",
              "onSkipped"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "webhook"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "endpoint": {
                "type": "string"
              },
              "event": {
                "type": "string"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "allowConfidential": {
                "type": "boolean"
              },
              "next": {
                "type": "string"
              },
              "onSkipped": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "endpoint",
              "event",
              "next",
              "onSkipped"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "skonto"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "leadDays": {
                "type": "integer"
              },
              "next": {
                "type": "string"
              },
              "onMissed": {
                "type": "string"
              },
              "onNone": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "leadDays",
              "next",
              "onMissed",
              "onNone"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "invoiceCheck"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "check": {
                "type": "string",
                "enum": [
                  "mandatoryDetails",
                  "orderMatch",
                  "contractMatch"
                ]
              },
              "next": {
                "type": "string"
              },
              "onDeviation": {
                "type": "string"
              },
              "onNotFound": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "order": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "invoiceField": {
                    "type": "string"
                  },
                  "orderType": {
                    "type": "string"
                  },
                  "orderField": {
                    "type": "string"
                  },
                  "tolerancePercent": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "toleranceAmount": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "invoiceVendorField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "orderVendorField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "deliveryNoteWaitStep": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "invoiceField",
                  "orderType",
                  "orderField"
                ],
                "additionalProperties": false
              },
              "contract": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "contractType": {
                    "type": "string"
                  },
                  "invoiceReferenceField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "contractReferenceField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "amountField": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "tolerancePercent": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                },
                "required": [
                  "contractType"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "name",
              "check",
              "next",
              "onDeviation"
            ],
            "additionalProperties": false
          },
          {
            "properties": {
              "kind": {
                "const": "signature"
              },
              "name": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "signers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "member",
                        "requester",
                        "external"
                      ]
                    },
                    "label": {
                      "type": "string"
                    },
                    "member": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "firstNameField": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "lastNameField": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "emailField": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "mobileField": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "label"
                  ],
                  "additionalProperties": false
                }
              },
              "ordered": {
                "type": "boolean"
              },
              "level": {
                "type": "string",
                "enum": [
                  "ses",
                  "aes",
                  "qes"
                ]
              },
              "expiryDays": {
                "type": "integer"
              },
              "fieldMode": {
                "type": "string",
                "enum": [
                  "typeTemplate",
                  "detect",
                  "reviewBeforeSend"
                ]
              },
              "reviewer": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "member",
                      "role",
                      "requester",
                      "costCenterResponsible",
                      "approvalLimit",
                      "deadlineOwner"
                    ]
                  },
                  "member": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "role": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "table": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              "allowConfidential": {
                "type": "boolean"
              },
              "language": {
                "type": "string"
              },
              "next": {
                "type": "string"
              },
              "onDeclined": {
                "type": "string"
              },
              "onExpired": {
                "type": "string"
              },
              "onSkipped": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "signers",
              "ordered",
              "level",
              "expiryDays",
              "fieldMode",
              "reviewer",
              "language",
              "next",
              "onDeclined",
              "onExpired",
              "onSkipped"
            ],
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "required": [
    "$schema",
    "format",
    "schemaVersion",
    "sdk",
    "key",
    "name",
    "template",
    "trigger",
    "fields",
    "start",
    "steps"
  ],
  "additionalProperties": false
}
