{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postedly-com/json-schema/postedly-com-order-schema.json",
  "title": "Order",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/postedly-com-api-openapi.json#/components/schemas/Order",
  "type": "object",
  "required": [
    "id",
    "service",
    "amountCents",
    "refundedCents",
    "currency",
    "paymentStatus",
    "fulfillmentStatus",
    "createdAt",
    "updatedAt",
    "recipient",
    "sender",
    "options",
    "timeline",
    "canCancel"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "orderUrl": {
      "type": "string",
      "format": "uri",
      "description": "Order page requiring existing access or receipt-email recovery."
    },
    "service": {
      "type": "string",
      "description": "Recorded service; historical orders can retain a service no longer offered."
    },
    "amountCents": {
      "type": "integer",
      "minimum": 0,
      "description": "Amount in integer US cents; never a floating-point dollar amount."
    },
    "refundedCents": {
      "type": "integer",
      "minimum": 0,
      "description": "Amount in integer US cents; never a floating-point dollar amount."
    },
    "currency": {
      "type": "string",
      "const": "usd",
      "description": "Order storage uses lowercase usd; quote responses use uppercase USD."
    },
    "paymentStatus": {
      "$ref": "#/$defs/PaymentStatus"
    },
    "fulfillmentStatus": {
      "$ref": "#/$defs/FulfillmentStatus"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "recipient": {
      "$ref": "#/$defs/Contact"
    },
    "sender": {
      "$ref": "#/$defs/Contact"
    },
    "receiptEmail": {
      "type": "string",
      "format": "email",
      "description": "The immutable receipt destination; distinct from the quoted postal sender. Private Postedly order emails remain withheld for guest checkouts until this address is verified; Stripe email prefill does not establish ownership."
    },
    "receiptEmailVerified": {
      "type": "boolean",
      "description": "Whether the receipt destination has been verified; false suppresses private order email."
    },
    "guestCheckout": {
      "type": "boolean",
      "description": "Whether this order was approved through the direct-browser guest flow."
    },
    "options": {
      "type": "object",
      "additionalProperties": true
    },
    "handwritten": {
      "$ref": "#/$defs/HandwrittenReview"
    },
    "addressWarnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AddressWarning"
      }
    },
    "document": {
      "$ref": "#/$defs/OrderDocument"
    },
    "checkoutUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Present only while the order awaits payment with paymentStatus checkout_pending, or failed after a declined card, and its hosted checkout is still open (60 minutes from approval); absent once that checkout expires or the order is cancelled. May be null only with checkout_pending, while checkout creation has not completed; a declined order with no hosted checkout (a shared payment token attempt) has none. Private URL, not payment evidence."
    },
    "timeline": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "$ref": "#/$defs/OrderEvent"
      },
      "description": "Up to 200 earliest events, in ascending timestamp order."
    },
    "canCancel": {
      "type": "boolean",
      "description": "True for awaiting_payment or queued. Advisory snapshot; a cancellation race may still return 409."
    },
    "evidence": {
      "type": "object",
      "additionalProperties": true,
      "description": "Optional provider-specific evidence. Fields vary by channel; do not assume a tracking number or proof of a recipient reading the item."
    }
  },
  "$defs": {
    "AddressWarning": {
      "type": "object",
      "required": [
        "role",
        "code",
        "message",
        "address"
      ],
      "description": "Immutable warning for one explicitly selected send-as-entered postal address. The browser review must obtain separate address-risk acceptance before payment.",
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "recipient",
            "sender"
          ]
        },
        "code": {
          "type": "string",
          "enum": [
            "address_unit_required",
            "address_unverified"
          ]
        },
        "message": {
          "type": "string"
        },
        "address": {
          "$ref": "#/$defs/Contact"
        }
      }
    },
    "Contact": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "fax": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "address1": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "postalCode": {
          "type": "string"
        },
        "country": {
          "type": "string",
          "default": "US"
        }
      }
    },
    "FulfillmentStatus": {
      "type": "string",
      "enum": [
        "awaiting_payment",
        "queued",
        "submitting",
        "submission_unknown",
        "submitted",
        "processing",
        "sent",
        "delivered",
        "failed",
        "cancelled"
      ],
      "description": "Recorded provider progression. submission_unknown requires reconciliation, never a blind resend. Fax delivered means all approved pages were confirmed by the receiving machine, not that a person read them. Postal statuses reflect available provider milestones."
    },
    "HandwrittenReview": {
      "type": "object",
      "required": [
        "cardId",
        "cardName",
        "cardImageUrl",
        "fontId",
        "fontLabel",
        "fontImageUrl",
        "message",
        "wishes",
        "sender",
        "recipient",
        "previewKind",
        "stampOptionId",
        "stampName"
      ],
      "description": "Immutable quoted card, handwriting style, exact text, postal addresses and postage option. Images are design/style samples, not a rendered final-message proof.",
      "properties": {
        "cardId": {
          "type": "string",
          "pattern": "^[1-9]\\d{0,14}$"
        },
        "cardName": {
          "type": "string"
        },
        "cardImageUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "fontId": {
          "type": "string"
        },
        "fontLabel": {
          "type": "string"
        },
        "fontImageUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "wishes": {
          "type": "string",
          "maxLength": 200
        },
        "sender": {
          "$ref": "#/$defs/Contact"
        },
        "recipient": {
          "$ref": "#/$defs/Contact"
        },
        "previewKind": {
          "type": "string",
          "const": "design_and_style_samples"
        },
        "stampOptionId": {
          "type": "integer"
        },
        "stampName": {
          "type": "string"
        }
      }
    },
    "OrderDocument": {
      "type": "object",
      "required": [
        "id",
        "name",
        "pages",
        "bytes",
        "sha256"
      ],
      "description": "Stored order document metadata; this response does not include a preview URL or contentType. Mail orders may refer to the source document, while the quote contains its final print proof.",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "pages": {
          "type": "integer",
          "minimum": 1
        },
        "bytes": {
          "type": "integer",
          "minimum": 1
        },
        "sha256": {
          "$ref": "#/$defs/Sha256"
        }
      }
    },
    "OrderEvent": {
      "type": "object",
      "required": [
        "id",
        "type",
        "message",
        "createdAt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Opaque event identifier, not necessarily a UUID."
        },
        "type": {
          "type": "string",
          "description": "Extensible event type; do not treat it as a payment/fulfillment enum."
        },
        "message": {
          "type": "string"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "PaymentStatus": {
      "type": "string",
      "enum": [
        "checkout_pending",
        "authorized",
        "paid",
        "failed",
        "cancelled",
        "refund_pending",
        "refunded"
      ],
      "description": "Separate from fulfillment. authorized is a hold, used for fax before capture following confirmed transmission. paid does not mean sent or delivered. refund_pending is not a completed refund."
    },
    "Sha256": {
      "type": "string",
      "pattern": "^[A-Fa-f0-9]{64}$",
      "description": "SHA-256 of the exact raw file bytes, as 64 hexadecimal characters."
    }
  }
}