{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/apisign-io/json-schema/apisign-io-contract-schema.json",
  "title": "Contract",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/apisign-io-openapi.yml#/components/schemas/Contract",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "status": {
      "$ref": "#/$defs/ContractStatus"
    },
    "org_id": {
      "type": "string"
    },
    "sent_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "expires_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Creation time plus expires_in_days. Signing links stop working after this."
    },
    "cancelled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "name": {
      "type": "string"
    },
    "content": {
      "type": "object",
      "properties": {
        "markdown": {
          "type": "string"
        }
      }
    },
    "fields": {
      "$ref": "#/$defs/StoredFields"
    },
    "template_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "final_pdf": {
      "type": "string",
      "description": "URL of the signed PDF; empty string until every signer has signed"
    },
    "metadata": {
      "type": "object"
    },
    "test_mode": {
      "type": "boolean"
    },
    "seal_document_hash": {
      "type": [
        "string",
        "null"
      ]
    },
    "seal_created_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "seal_certificate_serial": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "$defs": {
    "ContractStatus": {
      "type": "string",
      "enum": [
        "draft",
        "queued",
        "sent",
        "signed",
        "cancelled",
        "expired"
      ],
      "description": "`queued` is not set by any endpoint. `expired` is not currently set automatically: a contract past `expires_at` stays `sent`."
    },
    "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"
                }
              }
            }
          }
        }
      }
    }
  }
}