{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/apisign-io/json-schema/apisign-io-update-contract-request-schema.json",
  "title": "UpdateContractRequest",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/apisign-io-openapi.yml#/components/schemas/UpdateContractRequest",
  "type": "object",
  "required": [
    "contract_id"
  ],
  "properties": {
    "contract_id": {
      "type": "string",
      "description": "Contract ID (cuid)"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "template_id": {
      "type": "string",
      "description": "Changes the linked template; content is not re-rendered"
    },
    "content": {
      "type": "object",
      "properties": {
        "markdown": {
          "type": "string"
        }
      }
    },
    "fields": {
      "$ref": "#/$defs/StoredFields"
    },
    "metadata": {
      "type": "object"
    },
    "test_mode": {
      "type": "boolean",
      "description": "Must equal the current value"
    },
    "signers": {
      "type": "array",
      "description": "Replaces the signer list. Entries with an existing `id` are updated, others are added, and existing signers left out are deleted.",
      "items": {
        "type": "object",
        "required": [
          "email",
          "name",
          "mobile",
          "signing_order"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Existing signer ID"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "mobile": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
          },
          "company": {
            "type": "string",
            "maxLength": 255
          },
          "signing_order": {
            "type": "integer",
            "minimum": 1
          }
        }
      }
    }
  },
  "$defs": {
    "FieldDefinition": {
      "type": "object",
      "required": [
        "name",
        "type",
        "completedBy"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Variable name without braces"
        },
        "type": {
          "type": "string",
          "description": "signature, initials, signer_name, timestamp, text, email, phone or date"
        },
        "completedBy": {
          "type": "string",
          "enum": [
            "signer",
            "creator"
          ]
        },
        "label": {
          "type": "string",
          "description": "Prompt shown for a text field"
        }
      }
    },
    "StoredFields": {
      "type": [
        "object",
        "null"
      ],
      "description": "Field data as stored on a contract or template",
      "properties": {
        "fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FieldDefinition"
          }
        },
        "signers": {
          "type": "array",
          "description": "Per-signer field assignments, matched to signers by signing_order",
          "items": {
            "type": "object",
            "properties": {
              "signing_order": {
                "type": "integer"
              },
              "signerFields": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}