{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/korala-ai/json-schema/korala-ai-add-anchored-field-dto-schema.json",
  "title": "AddAnchoredFieldDto",
  "x-generated": "2026-11-14",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/korala-ai-openapi.json#/components/schemas/AddAnchoredFieldDto",
  "type": "object",
  "properties": {
    "valueKey": {
      "type": "string",
      "description": "Links repeated text fields for the same signer. Signer edits or clears one occurrence to update every field with this valueKey. Independent of the merge variable used for prefills."
    },
    "required": {
      "type": "boolean",
      "description": "Whether the signer must fill this field (default true)"
    },
    "editable": {
      "type": "boolean",
      "description": "When true, a prefilled value is a suggestion the signer can change before signing."
    },
    "sharedFill": {
      "type": "boolean",
      "description": "One signer owns the field, but until they sign any signer able to act may fill or correct it — the employer preparing a part the employee confirms. Refused on signature and initials fields."
    },
    "signingDate": {
      "type": "boolean",
      "description": "Date fields only. True fills the field with the date the signer signs: the signing page shows today and the signer does not type it. False makes it an ordinary date the signer enters. Refused on any other type."
    },
    "label": {
      "type": "string",
      "description": "Human-readable label shown to the signer for this field"
    },
    "acroFieldName": {
      "type": "string",
      "description": "Fully-qualified name of an embedded AcroForm field in the PDF (see GET /documents/{id}/form-fields). When set, the value is written through the PDF form field at completion — comb boxes, checkboxes, and length limits render natively — instead of being overlay-stamped at the coordinates."
    },
    "acroOptionValue": {
      "type": "string",
      "description": "For radio-group AcroForm fields: the option (export value) this field selects when checked."
    },
    "options": {
      "description": "Allowed values for dropdown fields. The signer picks one; fills with a value outside this list are rejected.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "maxLength": {
      "type": "number",
      "description": "Maximum characters accepted at fill time. Imported automatically from AcroForm comb fields by detection."
    },
    "inputMask": {
      "type": [
        "string",
        "null"
      ],
      "description": "Single-line signer input mask. Each # accepts one digit; Korala inserts every other character as a literal."
    },
    "validationPattern": {
      "type": "string",
      "description": "Regular expression the filled value must match (text and date fields). Rejected fills return validationMessage."
    },
    "validationMessage": {
      "type": "string",
      "description": "Signer-facing error when validationPattern does not match"
    },
    "dateFormat": {
      "type": "string",
      "description": "Date fields only: format the auto-filled date is rendered in. Combines D/DD, M/MM, and YY/YYYY tokens with a consistent \"-\", \"/\", or \".\" separator. Without it, a format hint in the label (e.g. \"Date (MM-DD-YYYY)\") applies, then the signer locale."
    },
    "groupKey": {
      "type": "string",
      "description": "Semantic group key. Checkbox members sharing a groupKey are mutually exclusive (checking one clears the others) even with distinct PDF fill targets — e.g. a W-9 federal tax classification."
    },
    "groupRequired": {
      "type": "boolean",
      "description": "Require at least one member of this field's group to be selected before signing can complete."
    },
    "requiredWhenFieldId": {
      "type": "string",
      "format": "uuid",
      "description": "Make this field conditionally required: it must be filled before signing only while the referenced field (same document, same signer) is checked/filled — e.g. a W-9 LLC tax-classification code required only when the LLC box is checked. Refused on choose-one group members."
    },
    "requiredWhenValue": {
      "type": "string",
      "description": "Narrow the condition to an exact value of the referenced field (e.g. a dropdown's \"Other\" choice). Omit to trigger on any checked/filled state."
    },
    "fontSize": {
      "type": "number",
      "description": "Point size the value is drawn at. Imported automatically from the PDF form field's default appearance; omit to fit the size to the box."
    },
    "textColor": {
      "type": "string",
      "description": "Color the value is drawn in, as #rrggbb"
    },
    "textAlign": {
      "description": "Horizontal alignment of the value inside the field box",
      "allOf": [
        {
          "$ref": "#/$defs/TextAlign"
        }
      ]
    },
    "fontFamily": {
      "type": "string",
      "description": "Base font the value is drawn in. Imported from the PDF form field; honored when the platform can render that face, otherwise the default font is used. Values written through the form field render in the form's own font regardless."
    },
    "multiline": {
      "type": "boolean",
      "description": "Whether the value may contain line breaks. Imported from multiline PDF form fields: the signer gets a multi-line editor and the value is laid out from the top of the box, wrapping to its width."
    },
    "signerId": {
      "type": "string"
    },
    "fieldType": {
      "type": "string",
      "enum": [
        "signature",
        "initials",
        "date",
        "text",
        "checkbox",
        "dropdown",
        "radio"
      ]
    },
    "anchorText": {
      "type": "string",
      "description": "Text in the PDF to place the field against"
    },
    "occurrence": {
      "type": "number",
      "description": "Which match to use when the text appears more than once, counting from 1 in reading order. Required in that case.",
      "minimum": 1
    },
    "position": {
      "type": "string",
      "enum": [
        "replace",
        "left",
        "right",
        "above",
        "below"
      ],
      "default": "right",
      "description": "Where the field goes relative to the text. \"right\" and \"left\" sit on the same line, the field resting on the bottom of the text; \"above\" and \"below\" share its left edge. A field given no height is no taller than the blank it stands in. \"replace\" covers the text and takes its size."
    },
    "offsetX": {
      "type": "number",
      "description": "Shift right, in points",
      "default": 0
    },
    "offsetY": {
      "type": "number",
      "description": "Shift down, in points",
      "default": 0
    },
    "width": {
      "type": "number",
      "description": "In points, rounded. Defaults to a size fit for the type."
    },
    "height": {
      "type": "number",
      "description": "In points, rounded. Defaults to a size fit for the type, and above or below a label to no more than the blank there."
    }
  },
  "required": [
    "signerId",
    "fieldType",
    "anchorText"
  ],
  "$defs": {
    "TextAlign": {
      "type": "string",
      "enum": [
        "left",
        "center",
        "right"
      ],
      "description": "Horizontal alignment of the value inside the field box"
    }
  }
}