{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucp.dev/2026-04-08/schemas/shopping/order.json",
  "name": "dev.ucp.shopping.order",
  "title": "Order",
  "description": "Order schema with line items, buyer-facing fulfillment expectations, and 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",
    "currency",
    "totals"
  ],
  "properties": {
    "ucp": {
      "$ref": "https://ucp.dev/2026-04-08/schemas/ucp.json#/$defs/response_order_schema"
    },
    "id": {
      "type": "string",
      "description": "Unique order identifier."
    },
    "label": {
      "type": "string",
      "description": "Human-readable label for identifying the order. MUST only be provided by the business."
    },
    "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-04-08/schemas/shopping/types/order_line_item.json"
      },
      "description": "Line items representing what was purchased — can change post-order via edits or exchanges."
    },
    "fulfillment": {
      "type": "object",
      "properties": {
        "expectations": {
          "type": "array",
          "items": {
            "$ref": "https://ucp.dev/2026-04-08/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-04-08/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-04-08/schemas/shopping/types/adjustment.json"
      },
      "description": "Post-order events (refunds, returns, credits, disputes, cancellations, etc.) that exist independently of fulfillment."
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency code. MUST match the currency from the originating checkout session.",
      "ucp_request": "omit"
    },
    "totals": {
      "$ref": "https://ucp.dev/2026-04-08/schemas/shopping/types/totals.json",
      "description": "Different totals for the order."
    },
    "messages": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/2026-04-08/schemas/shopping/types/message.json"
      },
      "description": "Business outcome messages (errors, warnings, informational). Present when the business needs to communicate status or issues to the platform."
    }
  },
  "version": "2026-04-08"
}