{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/namirial/main/json-schema/namirial-create-process-draft-request-schema.json",
  "title": "CreateProcessDraftRequest",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/namirial-connectors-openapi.yml#/components/schemas/CreateProcessDraftRequest",
  "type": "object",
  "properties": {
    "templateId": {
      "type": "string",
      "description": "Template Id"
    },
    "name": {
      "type": "string",
      "description": "Process name"
    },
    "documents": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Document"
      }
    },
    "events": {
      "type": "array",
      "maxItems": 2,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/ProcessFinishedEvent"
          }
        ]
      }
    },
    "recipients": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/Recipient"
          }
        ]
      }
    },
    "messageData": {
      "type": "object",
      "properties": {
        "emailSubject": {
          "type": "string",
          "description": "The subject specified in the email message sent to the recipients"
        },
        "emailBody": {
          "type": "string",
          "description": "The body specified in the email message sent to the recipients"
        }
      }
    }
  },
  "$defs": {
    "Document": {
      "type": "string"
    },
    "EmailAction": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Action type"
        },
        "to": {
          "type": "string",
          "description": "List of recipients emails separed by semicolon (;)",
          "maximum": 500
        },
        "cc": {
          "type": "string",
          "description": "List of carbon copy emails separed by semicolon (;)",
          "maximum": 500
        },
        "ccn": {
          "type": "string",
          "description": "List of blind carbon copy emails separed by semicolon (;)",
          "maximum": 200
        },
        "subject": {
          "type": "string",
          "description": "The email subject",
          "maximum": 100
        },
        "body": {
          "type": "string",
          "description": "The email body",
          "maximum": 500
        }
      },
      "required": [
        "type",
        "to",
        "subject",
        "body"
      ]
    },
    "HttpAction": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Action type"
        },
        "callbackUrl": {
          "type": "string",
          "description": "The url to call",
          "maximum": 250
        },
        "method": {
          "type": "string",
          "description": "The request HTTP Method (GET, POST are only supported)"
        },
        "envelopeGuidRequired": {
          "type": "boolean",
          "description": "Specify if the envelope guid must be add to the callback request"
        },
        "documentIds": {
          "type": "boolean",
          "description": "Specify if the document guids must be add to the callback request"
        }
      },
      "required": [
        "type",
        "callbackUrl",
        "method",
        "envelopeGuidRequired",
        "documentIds"
      ]
    },
    "ProcessFinishedEvent": {
      "type": "object",
      "properties": {
        "actions": {
          "type": "array",
          "maxItems": 5,
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/EmailAction"
              },
              {
                "$ref": "#/$defs/HttpAction"
              }
            ]
          }
        },
        "eventType": {
          "type": "string",
          "description": "The Esaw Callback event type (The supported event are : envelopeFinished,workstepFinished)"
        }
      },
      "required": [
        "eventType"
      ]
    },
    "Recipient": {
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string",
          "description": "The recipient first name for the draft"
        },
        "lastName": {
          "type": "string",
          "description": "The recipient last name for the draft"
        },
        "email": {
          "type": "string",
          "description": "The recipient email for the draft"
        },
        "languageCode": {
          "type": "string",
          "description": "The recipient language code for the draft"
        },
        "disableEmail": {
          "type": "boolean",
          "description": "Describe if the recipient receive or not email notification"
        },
        "overrideOptions": {
          "type": "object",
          "properties": {
            "orderIndex": {
              "type": "integer",
              "description": "Recipient to override order index"
            },
            "email": {
              "type": "string",
              "description": "Recipient to override email"
            }
          }
        }
      }
    }
  }
}