{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/signvoy-com/json-schema/signvoy-com-document-dto-schema.json",
  "title": "DocumentDto",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/signvoy-com-openapi.json#/components/schemas/DocumentDto",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "templateId": {
      "type": "string",
      "format": "uuid"
    },
    "templateVersionId": {
      "type": "string",
      "format": "uuid"
    },
    "ownerId": {
      "type": "string",
      "description": "Clerk user ID of the document owner"
    },
    "name": {
      "type": "string",
      "description": "Human-readable document name"
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "sent",
        "in_progress",
        "completed",
        "declined",
        "voided",
        "expired"
      ],
      "description": "Current document lifecycle state"
    },
    "routingMode": {
      "type": "string",
      "enum": [
        "parallel",
        "sequential"
      ],
      "description": "Signing-order mode"
    },
    "message": {
      "type": "string",
      "description": "Custom message sent with the signing request"
    },
    "emailSubject": {
      "type": "string",
      "description": "Sender's replacement subject for the signing request and reminders. Absent means the generated subject is used."
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (Unix ms)"
    },
    "sentAt": {
      "type": "integer",
      "description": "Unix ms when sent"
    },
    "completedAt": {
      "type": "integer",
      "description": "Unix ms when all signed"
    },
    "voidedAt": {
      "type": "integer",
      "description": "Unix ms when voided"
    },
    "expiresAt": {
      "type": "integer",
      "description": "Unix ms when expires/expired"
    },
    "documentHash": {
      "type": "string",
      "description": "SHA-256 fingerprint of the certified final PDF"
    },
    "certifiedAt": {
      "type": "integer",
      "description": "Unix ms when certified"
    },
    "reminderEnabled": {
      "type": "boolean",
      "description": "Whether automatic reminders are enabled"
    },
    "reminderIntervalDays": {
      "type": "integer",
      "description": "Days between automatic reminders"
    },
    "reminderMaxCount": {
      "type": "integer",
      "description": "Max automatic reminders"
    },
    "reminderCount": {
      "type": "integer",
      "description": "Automatic reminders sent so far"
    },
    "lastReminderAt": {
      "type": "integer",
      "description": "Unix ms of the most recent reminder (auto or manual)"
    },
    "recipients": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentRecipientDto"
      }
    },
    "previewPins": {
      "type": "array",
      "description": "Positions (percent of page) of up to 8 fields on page 1 of the pinned template version, for list thumbnails. `recipientKey` matches `recipients[].roleKey`. Only returned by the list endpoint.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "recipientKey": {
            "type": "string"
          },
          "x": {
            "type": "number"
          },
          "y": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "recipientKey",
          "x",
          "y"
        ]
      }
    },
    "sendBlockers": {
      "type": "array",
      "description": "Reasons a draft cannot yet be sent. Empty array when the document is ready to send or is not in draft state.",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "NO_RECIPIENTS",
              "RECIPIENT_EMAIL_MISSING",
              "CC_EMAIL_MISSING"
            ]
          },
          "message": {
            "type": "string"
          },
          "recipientIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    }
  },
  "required": [
    "id",
    "workspaceId",
    "templateId",
    "templateVersionId",
    "ownerId",
    "name",
    "status",
    "routingMode",
    "createdAt",
    "reminderEnabled",
    "reminderIntervalDays",
    "reminderMaxCount",
    "reminderCount",
    "recipients",
    "sendBlockers"
  ],
  "$defs": {
    "DocumentRecipientDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "roleKey": {
          "type": "string",
          "description": "Matches template version recipient key"
        },
        "roleName": {
          "type": "string",
          "description": "Role display name snapshot at send time"
        },
        "type": {
          "type": "string",
          "enum": [
            "signer",
            "cc",
            "viewer"
          ],
          "description": "What this recipient is asked to do. `signer` fills in fields and signs. `cc` receives a copy and never holds up the signing order. `viewer` must open and confirm they reviewed the document."
        },
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "description": "Recipient email address"
        },
        "color": {
          "type": "string",
          "description": "Hex colour assigned to this recipient"
        },
        "order": {
          "type": "integer",
          "description": "Signing order (0-based)"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "signed",
            "acknowledged",
            "copy_sent",
            "declined"
          ],
          "description": "Each role reaches its own terminal status: a signer `signed`, a viewer `acknowledged`, a CC `copy_sent`. They are never interchangeable."
        },
        "signedAt": {
          "type": "integer",
          "description": "Unix ms timestamp when recipient signed"
        },
        "declinedAt": {
          "type": "integer",
          "description": "Unix ms timestamp when recipient declined"
        },
        "declineReason": {
          "type": "string",
          "description": "Reason for declining"
        },
        "signUrl": {
          "type": "string",
          "description": "URL where this recipient can complete signing"
        },
        "lastRemindedAt": {
          "type": "integer",
          "description": "Unix ms timestamp when recipient was last reminded (manual or automatic)"
        },
        "hasActiveSigningLink": {
          "type": "boolean",
          "description": "Whether this recipient has an active signing link (can currently sign)"
        }
      },
      "required": [
        "id",
        "roleKey",
        "roleName",
        "type",
        "name",
        "color",
        "order",
        "status"
      ]
    }
  }
}