{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assinafy-com-br/json-schema/assinafy-com-br-document-contract-input-schema.json",
  "title": "DocumentContractInput",
  "description": "Every attribute is optional and only the ones sent change. `null` clears an attribute, except `auto_renew` (back to `false`) and `currency` (back to `BRL` while a `value` is set); `status` does not accept `null`. A changed `end_date` starts a new `term`.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assinafy-com-br-openapi.json#/components/schemas/DocumentContractInput",
  "properties": {
    "status": {
      "description": "On creation any status, so a contract that ended before it was tracked is registered as it ended: `expired` needs an `end_date` in the past, `terminated` its `end_date`; neither is walked by the lifecycle. Afterwards only `draft` or `active` (a contract in force never goes back to `draft`): `expired` and `terminated` are set by the lifecycle and the terminate endpoint; a closed contract is reopened by renewing it.",
      "type": "string",
      "enum": [
        "draft",
        "active",
        "expired",
        "terminated"
      ]
    },
    "counterparty_name": {
      "description": "Emoji are kept; other characters outside the 3-byte range are dropped.",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 255
    },
    "counterparty_taxpayer_id": {
      "description": "A valid CPF or CNPJ, formatted or not.",
      "type": [
        "string",
        "null"
      ]
    },
    "value": {
      "description": "Two decimal places at most.",
      "type": [
        "number",
        "null"
      ],
      "maximum": 9999999999999.99,
      "minimum": 0
    },
    "currency": {
      "description": "Three letters, such as `BRL` or `USD`, stored in capitals; `BRL` when a `value` is set without one.",
      "type": [
        "string",
        "null"
      ]
    },
    "start_date": {
      "description": "`YYYY-MM-DD`, from the year 1000.",
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "end_date": {
      "description": "`YYYY-MM-DD`, on or after `start_date`.",
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "auto_renew": {
      "description": "Whether the hourly run starts the next term the day after `end_date`, by `renewal_term_months`, instead of expiring the contract.",
      "type": "boolean"
    },
    "renewal_term_months": {
      "description": "How far a renewal by the term moves `end_date`; 12 when unset.",
      "type": [
        "integer",
        "null"
      ],
      "maximum": 600,
      "minimum": 1
    },
    "notice_period_days": {
      "description": "Days before `end_date` the notice period starts (`document_contract_renewal_notice`); none when unset.",
      "type": [
        "integer",
        "null"
      ],
      "maximum": 3650,
      "minimum": 0
    },
    "owner_id": {
      "description": "An active member of this workspace.",
      "type": [
        "string",
        "null"
      ]
    },
    "metadata": {
      "description": "Your own fields: up to 50 keys of 1 to 40 letters, digits, `_`, `-` or `.`, each holding plain text of at most 500 characters; no number under a key ending in `_at`, or `stuck_since`.",
      "maxProperties": 50,
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string",
        "maxLength": 500
      }
    },
    "external_references": {
      "description": "Replaces the whole list; `[]` or `null` clears it. Two items whose `system` and `id` compare equal case aside are one reference (the first sent is kept); a pair the database takes for one beyond that (accents, `ß` and `ss`) answers `400`.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "required": [
          "system",
          "id"
        ],
        "properties": {
          "system": {
            "description": "Letters, digits, `_`, `-` and `.`; stored in lower case.",
            "type": "string",
            "maxLength": 64
          },
          "id": {
            "description": "Kept as sent; must not contain emoji or other 4-byte characters.",
            "type": "string",
            "maxLength": 255
          }
        },
        "type": "object"
      },
      "maxItems": 20
    },
    "parent_document_id": {
      "description": "Links the document as an amendment of this contract document, or of any document in its family (resolved to the root); `null` unlinks a pending amendment. With it, the other attributes are the terms the instrument changes, not terms of its own; on a pending amendment a `null` value drops that term from the delta rather than clearing it on the parent.",
      "type": [
        "string",
        "null"
      ]
    },
    "relation_type": {
      "description": "Required on the first link. `amendment` may change `value`, `currency`, `start_date` (effective from, display only), `end_date`, `auto_renew`, `renewal_term_months`, `notice_period_days`, `counterparty_name`, `counterparty_taxpayer_id` and `metadata`; `renewal` only `end_date` and `value`; `termination` only `end_date` (the effective date).",
      "type": "string",
      "enum": [
        "amendment",
        "renewal",
        "termination"
      ]
    },
    "updated_at": {
      "description": "Optional precondition: the `updated_at` the client read the contract (or this document's amendment link) with, as the API returned it. If the contract or link changed since, nothing is written and the answer is `409` with `code: ContractChanged`. Not sent, or `null`: the write applies whatever changed meanwhile (last write wins). Compared to the second; a fraction of a second, as a JavaScript date prints it, is read and ignored. New terms and a first link have nothing to have read, so sending one answers `409`; on a pending amendment, send the link's own `updated_at` (the GET on that document).",
      "type": "string",
      "format": "date-time"
    }
  },
  "type": "object"
}