{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assinafy-com-br/json-schema/assinafy-com-br-document-schema.json",
  "title": "Document",
  "description": "A document and its current lifecycle state.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assinafy-com-br-openapi.json#/components/schemas/Document",
  "properties": {
    "resource": {
      "description": "Present in single-resource responses.",
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "account_id": {
      "type": "string"
    },
    "template_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "type": "string"
    },
    "status": {
      "description": "Status code — see GET /v1/documents/statuses.",
      "type": "string"
    },
    "artifacts": {
      "description": "Artifact download URLs keyed by name. Always `original`, plus `thumbnail` once one exists. A certificated document also carries `certificated`, `certificate-page` and `bundle`, and `pades` when it was signed with a digital certificate — the PAdES version holds the signers' ICP-Brasil signatures, which certification flattens out of the certificated PDF.",
      "type": "object"
    },
    "is_closed": {
      "type": "boolean"
    },
    "signing_url": {
      "type": "string"
    },
    "verification_code": {
      "description": "The code printed on the certificate page. Anyone can check it with `GET /v1/documents/{verification_code}/verify` or on `verification_url`. `null` until the document is `certificated`, and on documents certificated before verification codes existed.",
      "type": [
        "string",
        "null"
      ]
    },
    "verification_url": {
      "description": "The public verification page for this document. `null` until the document is `certificated`.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "decline_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "declined_by": {
      "oneOf": [
        {
          "$ref": "#/$defs/Signer"
        },
        {
          "type": "null"
        }
      ]
    },
    "tags": {
      "type": "array",
      "items": {
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "type": "object"
      }
    },
    "assignment": {
      "description": "The document's assignment, or `null` before one is created. The server decides when it is included, whatever `expand` the request sends: the document list, `GET /v1/documents/{documentId}`, the signer's document list and document creation from a template always include it; `/documents/search` and the upload response never do. Only the rename response follows `?expand=assignment`.",
      "oneOf": [
        {
          "$ref": "#/$defs/Assignment"
        },
        {
          "type": "null"
        }
      ]
    },
    "pages": {
      "description": "The document's pages. Included on the same responses as `assignment`, and also on the upload response.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentPage"
      }
    },
    "has_contract": {
      "description": "Only on `GET /v1/documents/{documentId}` read by the workspace, while the environment has contract tracking on: not with a signer's access code, not in document lists or webhooks, and left out when the lookup fails, so a missing key means unknown. Whether `GET /v1/accounts/{accountId}/documents/{documentId}/contract` answers with contract terms, the document's own or those of a contract it amends whose document still exists, so a page can lay out the contract section before reading it.",
      "type": "boolean"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "type": "object",
  "$defs": {
    "Assignment": {
      "description": "A request for signers to sign a document.",
      "properties": {
        "resource": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "document_id": {
          "description": "The document this assignment belongs to. `null` only if the document was deleted.",
          "type": [
            "string",
            "null"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "sender_email": {
          "description": "Email of the user who sent the document; null once that user has deleted their account.",
          "type": [
            "string",
            "null"
          ],
          "format": "email"
        },
        "method": {
          "type": "string",
          "enum": [
            "virtual",
            "collect"
          ]
        },
        "expires_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "message": {
          "type": [
            "string",
            "null"
          ]
        },
        "signers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AssignmentSigner"
          }
        },
        "copy_receivers": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AssignmentItem"
          }
        },
        "summary": {
          "$ref": "#/$defs/AssignmentSummary"
        },
        "signing_urls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SigningUrl"
          }
        }
      },
      "type": "object"
    },
    "AssignmentItem": {
      "properties": {
        "id": {
          "type": "string"
        },
        "page": {
          "oneOf": [
            {
              "$ref": "#/$defs/DocumentPage"
            },
            {
              "type": "null"
            }
          ]
        },
        "signer": {
          "description": "Signer responsible for this item.",
          "type": "object"
        },
        "field": {
          "description": "Field definition associated with the item.",
          "type": [
            "object",
            "null"
          ]
        },
        "display_settings": {
          "description": "Rendering metadata for the item. Collect items use the DisplaySettings schema; virtual and legacy items may return an empty or non-object value."
        },
        "value": {
          "description": "Captured value when completed; `null` until then."
        },
        "completed": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "AssignmentSigner": {
      "description": "A signer within an assignment: the base Signer plus per-assignment verification/notification details.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/Signer"
        },
        {
          "properties": {
            "verification_method": {
              "type": [
                "string",
                "null"
              ]
            },
            "notification_methods": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "step": {
              "description": "Sequential signing step (defaults to 1).",
              "type": [
                "integer",
                "null"
              ]
            },
            "notified": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "identity_verification_status": {
              "description": "Latest identity-document verification status; `InReview` means the account must decide it before the document can be certificated.",
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "Pending",
                "InReview",
                "Approved",
                "Declined",
                "Expired",
                "Abandoned"
              ]
            },
            "completed": {
              "description": "Only present in account-owner contexts.",
              "type": [
                "boolean",
                "null"
              ]
            },
            "notification_history": {
              "description": "Per-channel delivery history for this signer (email + WhatsApp), most-recent send order.",
              "type": [
                "array",
                "null"
              ],
              "items": {
                "$ref": "#/$defs/NotificationHistoryEntry"
              }
            }
          },
          "type": "object"
        }
      ]
    },
    "AssignmentSummary": {
      "properties": {
        "signer_count": {
          "type": "integer"
        },
        "completed_count": {
          "type": "integer"
        },
        "signers": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "type": "object"
    },
    "DocumentPage": {
      "properties": {
        "id": {
          "type": "string"
        },
        "number": {
          "type": "integer"
        },
        "height": {
          "type": "integer"
        },
        "width": {
          "type": "integer"
        },
        "download_url": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "NotificationHistoryEntry": {
      "description": "A single notification delivery record for a signer channel.",
      "properties": {
        "event": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "sent",
            "failed"
          ]
        },
        "error_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "error_message": {
          "type": [
            "string",
            "null"
          ]
        },
        "sent_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "failed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "type": "object"
    },
    "Signer": {
      "description": "A signing party belonging to a workspace account.",
      "properties": {
        "resource": {
          "description": "Present in single-resource responses.",
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "full_name": {
          "type": "string"
        },
        "email": {
          "type": [
            "string",
            "null"
          ],
          "format": "email"
        },
        "whatsapp_phone_number": {
          "description": "E.164 format; normalized on save.",
          "type": [
            "string",
            "null"
          ]
        },
        "government_id": {
          "description": "Signer's normalized CPF (11 digits) or CNPJ (14 characters; may be alphanumeric).",
          "type": [
            "string",
            "null"
          ]
        },
        "has_accepted_terms": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "SigningUrl": {
      "properties": {
        "signer_id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}