{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-record-document-dto-schema.json",
  "title": "RecordDocumentDto",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-files-api-openapi.yml#/components/schemas/RecordDocumentDto",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "recordId": {
      "type": "string"
    },
    "parentId": {
      "type": [
        "string",
        "null"
      ]
    },
    "kind": {
      "allOf": [
        {
          "$ref": "#/$defs/FileItemKind"
        }
      ]
    },
    "name": {
      "type": "string"
    },
    "file": {
      "$ref": "#/$defs/FileAttachment"
    },
    "state": {
      "allOf": [
        {
          "$ref": "#/$defs/FileItemState"
        }
      ]
    },
    "sourceId": {
      "type": "string"
    },
    "envelopeId": {
      "type": "string"
    },
    "fieldCount": {
      "type": "number",
      "description": "How many signing fields are placed on it"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdBy": {
      "type": "string"
    },
    "content": {
      "$ref": "#/$defs/DocumentContentDto"
    },
    "page": {
      "$ref": "#/$defs/DocumentPageDto"
    },
    "fields": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SigningFieldDto"
      }
    }
  },
  "required": [
    "id",
    "recordId",
    "parentId",
    "kind",
    "name",
    "state",
    "fieldCount",
    "createdAt",
    "content",
    "page",
    "fields"
  ],
  "$defs": {
    "DocumentContentDto": {
      "type": "object",
      "properties": {
        "blocks": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "settings": {
          "type": "object"
        },
        "pdf": {
          "type": "object"
        }
      },
      "required": [
        "blocks"
      ]
    },
    "DocumentMarginDto": {
      "type": "object",
      "properties": {
        "top": {
          "type": "number"
        },
        "right": {
          "type": "number"
        },
        "bottom": {
          "type": "number"
        },
        "left": {
          "type": "number"
        }
      }
    },
    "DocumentPageDto": {
      "type": "object",
      "properties": {
        "size": {
          "allOf": [
            {
              "$ref": "#/$defs/PaperSize"
            }
          ]
        },
        "landscape": {
          "type": "boolean"
        },
        "margin": {
          "$ref": "#/$defs/DocumentMarginDto"
        },
        "header": {
          "type": "string"
        },
        "footer": {
          "type": "string"
        },
        "pageNumbers": {
          "type": "boolean"
        }
      }
    },
    "FileAttachment": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "fileName": {
          "type": "string"
        },
        "fileSize": {
          "type": "number"
        },
        "mime": {
          "type": "string"
        },
        "isInline": {
          "type": "boolean"
        },
        "contentId": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "path",
        "fileName",
        "fileSize",
        "mime"
      ]
    },
    "FileItemKind": {
      "type": "string",
      "enum": [
        "folder",
        "upload",
        "document"
      ]
    },
    "FileItemState": {
      "type": "string",
      "enum": [
        "draft",
        "final",
        "sending",
        "signed",
        "declined",
        "voided",
        "expired"
      ]
    },
    "PaperSize": {
      "type": "string",
      "enum": [
        "a4",
        "a5",
        "us-letter",
        "us-legal"
      ]
    },
    "SigningFieldDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "description": "Who fills it: a party role, \"Sender\" or \"Record\""
        },
        "kind": {
          "allOf": [
            {
              "$ref": "#/$defs/SigningFieldKind"
            }
          ]
        },
        "page": {
          "type": "number",
          "description": "0-based page index"
        },
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "w": {
          "type": "number"
        },
        "h": {
          "type": "number"
        },
        "required": {
          "type": "boolean"
        },
        "label": {
          "type": "string"
        },
        "fontSize": {
          "type": "number"
        },
        "options": {
          "description": "Choices of a select",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "value": {
          "type": "string",
          "description": "What a field filled from the record prints, as Liquid"
        }
      },
      "required": [
        "id",
        "role",
        "kind",
        "page",
        "x",
        "y",
        "w",
        "h",
        "required"
      ]
    },
    "SigningFieldKind": {
      "type": "string",
      "enum": [
        "signature",
        "initials",
        "date_signed",
        "full_name",
        "email",
        "text",
        "number",
        "checkbox",
        "select"
      ]
    }
  }
}