{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/printandmailcompany-com/json-schema/printandmailcompany-com-letter-schema.json",
  "title": "Letter",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/printandmailcompany-com-api-openapi.json#/components/schemas/Letter",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "reference": {
      "type": "string",
      "description": "Shown to the customer and on receipts, e.g. PM-7K3QX9"
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "paid",
        "in_production",
        "printed",
        "posted",
        "cancelled",
        "returned"
      ]
    },
    "documentId": {
      "type": "string"
    },
    "recipient": {
      "$ref": "#/$defs/Address"
    },
    "recipientLines": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The address as printed on the envelope"
    },
    "options": {
      "type": "object",
      "properties": {
        "pages": {
          "type": "integer"
        },
        "duplex": {
          "type": "boolean"
        },
        "color": {
          "type": "string",
          "enum": [
            "bw",
            "color"
          ]
        },
        "envelope": {
          "type": "string",
          "enum": [
            "DL",
            "C5",
            "C4"
          ]
        },
        "registered": {
          "type": "boolean"
        },
        "paper": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "a4",
            "us_letter",
            null
          ],
          "description": "Paper the letter is printed on, fixed at payment; null while the paper choice is pending; absent on letters from before 8 October 2026 (A4)"
        },
        "paperChoice": {
          "type": "string",
          "enum": [
            "a4",
            "us_letter"
          ],
          "description": "The paper the customer chose for a US Letter document to a destination outside the US, Canada and US territories"
        }
      }
    },
    "paperSize": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "a4",
        "us_letter",
        null
      ],
      "description": "Paper the letter is printed on (a draft's as decided from its document now, a paid letter's as fixed at payment); null while the customer still has to choose (paperChoiceRequired)"
    },
    "paperChoiceRequired": {
      "type": "boolean",
      "description": "A US Letter document to a destination outside the US, Canada and US territories, and no choice yet: ask \"shrink to A4 (recommended) or keep US Letter?\" and send paperSize with /letters/{id}/send. Sending without it answers 409 PAPER_CHOICE_REQUIRED."
    },
    "destinationPaperSize": {
      "type": "string",
      "enum": [
        "a4",
        "us_letter"
      ],
      "description": "Standard paper of the destination: us_letter for US, CA, PR, VI, GU, AS, MP, else a4"
    },
    "currency": {
      "type": "string",
      "enum": [
        "EUR",
        "USD",
        "GBP",
        "CHF"
      ]
    },
    "total": {
      "type": "integer",
      "description": "Total in minor units of currency"
    },
    "totalFormatted": {
      "type": "string"
    },
    "quote": {
      "type": "object",
      "description": "Price breakdown in EUR cents (lines, netEurCents, vatEurCents, grossEurCents, vatRate, reverseCharge), postal size class and zone"
    },
    "priceLabel": {
      "type": "string",
      "description": "\"incl. <rate> VAT\" with the current VAT rate, or \"excl. VAT — reverse charge\""
    },
    "trackingNumber": {
      "type": [
        "string",
        "null"
      ],
      "description": "Registered letters, once posted"
    },
    "createdVia": {
      "type": "string",
      "enum": [
        "web",
        "mcp",
        "api"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "paidAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "postedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "cancelledAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "The letter's page in the customer's account, in the account's language: the print-ready PDF (page previews, open, download) until the retention period ends, the status and the price. Give it to the account holder to check the letter before sending; it needs their sign-in."
    }
  },
  "$defs": {
    "Address": {
      "type": "object",
      "required": [
        "name",
        "line1",
        "city",
        "country"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 60
        },
        "company": {
          "type": "string",
          "maxLength": 60
        },
        "line1": {
          "type": "string",
          "maxLength": 60,
          "description": "Street and number or PO box"
        },
        "line2": {
          "type": "string",
          "maxLength": 60
        },
        "postalCode": {
          "type": "string",
          "maxLength": 16
        },
        "city": {
          "type": "string",
          "maxLength": 50
        },
        "region": {
          "type": "string",
          "maxLength": 50,
          "description": "State/province where used (e.g. US state code)"
        },
        "country": {
          "type": "string",
          "minLength": 2,
          "maxLength": 2,
          "description": "ISO 3166-1 alpha-2"
        }
      }
    }
  }
}