{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/cm-com/main/json-schema/cm-com-create-template-schema.json",
  "title": "CreateTemplate",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cm-com-sign-v1-openapi.yml#/components/schemas/CreateTemplate",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Name of the template.",
      "maxLength": 255
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/$defs/FileReference"
          }
        }
      }
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/$defs/FileReference"
          }
        }
      }
    },
    "invitees": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The placeholder name of the recipient."
          }
        }
      }
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/$defs/FieldType"
          },
          "required": {
            "type": "boolean",
            "description": "Boolean for if the field is required to be filled by the invitee."
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value of the field, if the type is 'label'.",
            "maxLength": 255
          },
          "file": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The index of the file in this request to link the field to, starting from 0."
          },
          "invitee": {
            "type": "integer",
            "description": "The index of the invitee in this request to link the field to, starting from 0."
          },
          "locations": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/FieldLocation"
            }
          }
        },
        "required": [
          "type",
          "required",
          "invitee"
        ]
      }
    }
  },
  "required": [
    "name"
  ],
  "$defs": {
    "FieldLocation": {
      "type": "object",
      "properties": {
        "range": {
          "type": "string",
          "pattern": "^\\d+(-\\d+)?$",
          "maxLength": 64,
          "description": "The page number within the PDF that this field occupies (e.g. `1`), or range for a initials field (e.g. `1-3`)."
        },
        "x": {
          "type": "number",
          "format": "float",
          "description": "X position of the field in points."
        },
        "y": {
          "type": "number",
          "format": "float",
          "description": "Y position of the field in points."
        },
        "width": {
          "type": "number",
          "format": "float",
          "description": "Width of the field in points."
        },
        "height": {
          "type": "number",
          "format": "float",
          "description": "Height of the field in points."
        }
      }
    },
    "FieldType": {
      "type": "string",
      "description": "The type of field for the invitee.",
      "enum": [
        "signature",
        "signatureDate",
        "initials",
        "text",
        "textarea",
        "label",
        "checkbox",
        "radio",
        "stamp"
      ]
    },
    "FileReference": {
      "type": "string",
      "format": "uuid",
      "description": "A unique reference number for this file."
    }
  }
}