{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sendletter-eu/json-schema/sendletter-eu-letter-schema.json",
  "title": "Letter",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sendletter-eu-openapi.json#/components/schemas/Letter",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Use this to poll status and to reconcile invoices."
    },
    "mode": {
      "type": "string",
      "enum": [
        "test",
        "live"
      ],
      "description": "Which kind of key created it. A test letter is never printed, never posted and never charged for, and says so here and in every callback about it."
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "scheduled",
        "awaiting_payment",
        "paid",
        "queued",
        "processing",
        "attention_required",
        "submitted",
        "printed",
        "posted",
        "delivered",
        "failed",
        "cancelled",
        "returned",
        "refund_pending",
        "refunded"
      ],
      "description": "queued means accepted and waiting on the print partner. posted is the moment the legal clock starts and is what a response deadline should be counted from."
    },
    "statusDetail": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why it is waiting, or why it failed."
    },
    "pages": {
      "type": "integer"
    },
    "sheets": {
      "type": "integer"
    },
    "destination": {
      "type": "string"
    },
    "product": {
      "type": "string"
    },
    "colour": {
      "type": "boolean"
    },
    "duplex": {
      "type": "boolean"
    },
    "priceCents": {
      "type": "integer",
      "description": "Excluding VAT."
    },
    "vatCents": {
      "type": "integer"
    },
    "totalCents": {
      "type": "integer",
      "description": "Including VAT. This is what is charged."
    },
    "currency": {
      "type": "string",
      "enum": [
        "EUR"
      ]
    },
    "trackingCode": {
      "type": [
        "string",
        "null"
      ]
    },
    "billedToOrganizationId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The organisation that paid for this letter, null when it came out of your own wallet. Present on every read so an integrator sending for several companies can reconcile without keeping its own record."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "postedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "timeline": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/TimelineEntry"
      },
      "description": "Every status this letter has been in. Returned when reading one letter."
    }
  },
  "$defs": {
    "TimelineEntry": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string"
        },
        "message": {
          "type": [
            "string",
            "null"
          ]
        },
        "at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}