{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucp.dev/2026-01-23/schemas/shopping/order.json",
  "name": "dev.ucp.shopping.order",
  "title": "Order",
  "description": "Order schema with immutable line items, buyer-facing fulfillment expectations, and append-only event logs.",
  "$defs": {
    "platform_schema": {
      "title": "Platform Order Schema",
      "description": "Platform's order capability configuration.",
      "type": "object",
      "required": [
        "webhook_url"
      ],
      "properties": {
        "webhook_url": {
          "type": "string",
          "format": "uri",
          "description": "URL where merchant sends order lifecycle events (webhooks)."
        }
      }
    }
  },
  "type": "object",
  "required": [
    "ucp",
    "id",
    "checkout_id",
    "permalink_url",
    "line_items",
    "fulfillment",
    "totals"
  ],
  "properties": {
    "ucp": {
      "$ref": "https://ucp.dev/2026-01-23/schemas/ucp.json#/$defs/response_order_schema"
    },
    "id": {
      "type": "string",
      "description": "Unique order identifier."
    },
    "checkout_id": {
      "type": "string",
      "description": "Associated checkout ID for reconciliation."
    },
    "permalink_url": {
      "type": "string",
      "format": "uri",
      "description": "Permalink to access the order on merchant site."
    },
    "line_items": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/2026-01-23/schemas/shopping/types/order_line_item.json"
      },
      "description": "Immutable line items — source of truth for what was ordered."
    },
    "fulfillment": {
      "type": "object",
      "properties": {
        "expectations": {
          "type": "array",
          "items": {
            "$ref": "https://ucp.dev/2026-01-23/schemas/shopping/types/expectation.json"
          },
          "description": "Buyer-facing groups representing when/how items will be delivered. Can be split, merged, or adjusted post-order."
        },
        "events": {
          "type": "array",
          "items": {
            "$ref": "https://ucp.dev/2026-01-23/schemas/shopping/types/fulfillment_event.json"
          },
          "description": "Append-only event log of actual shipments. Each event references line items by ID."
        }
      },
      "description": "Fulfillment data: buyer expectations and what actually happened."
    },
    "adjustments": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/2026-01-23/schemas/shopping/types/adjustment.json"
      },
      "description": "Append-only event log of money movements (refunds, returns, credits, disputes, cancellations, etc.) that exist independently of fulfillment."
    },
    "totals": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/2026-01-23/schemas/shopping/types/total.json"
      },
      "description": "Different totals for the order."
    }
  },
  "version": "2026-01-23"
}