{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/apisign-io/json-schema/apisign-io-template-schema.json",
  "title": "Template",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/apisign-io-templates-api-openapi.yml#/components/schemas/Template",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "org_id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "content": {
      "type": [
        "string",
        "null"
      ],
      "description": "Markdown with {{variables}}"
    },
    "fields": {
      "$ref": "#/$defs/StoredFields"
    },
    "archived": {
      "type": "boolean"
    },
    "test_mode": {
      "type": "boolean"
    }
  },
  "$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"
                }
              }
            }
          }
        }
      }
    }
  }
}