{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucp.dev/draft/schemas/food/checkout.json",
  "name": "dev.ucp.food.checkout",
  "title": "Checkout",
  "description": "Base checkout schema. Extensions compose onto this using allOf.",
  "type": "object",
  "required": [
    "ucp",
    "id",
    "food_establishment",
    "line_items",
    "status",
    "currency",
    "totals",
    "links"
  ],
  "anyOf": [
    {
      "properties": {
        "food_establishment": {
          "ucp_request": {
            "create": "required",
            "update": "omit",
            "complete": "omit"
          },
          "ucp_response": "omit"
        },
        "line_items": {
          "ucp_request": {
            "create": "required",
            "update": "omit",
            "complete": "omit"
          },
          "ucp_response": "omit"
        }
      }
    },
    {
      "properties": {
        "cart_id": {
          "ucp_request": {
            "create": "required",
            "update": "omit",
            "complete": "omit"
          },
          "ucp_response": "omit"
        }
      }
    }
  ],
  "properties": {
    "ucp": {
      "$ref": "https://ucp.dev/draft/schemas/ucp.json#/$defs/response_checkout_schema",
      "ucp_request": "omit"
    },
    "id": {
      "type": "string",
      "description": "Unique identifier of the checkout session.",
      "ucp_request": "omit"
    },
    "food_establishment": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/location_summary.json",
      "description": "Food establishment location the checkout is associated with. In create requests, required when initializing with inline `line_items` and optional when initializing via `cart_id`. Required in update requests and checkout responses.",
      "ucp_request": {
        "create": "optional",
        "update": "required",
        "complete": "omit"
      }
    },
    "line_items": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/draft/schemas/food/types/line_item.json"
      },
      "description": "List of dishes being checked out. In create requests, the Platform MUST include `line_items` (with `food_establishment`) or `cart_id`, and MAY include both. The Platform MUST include `line_items` in update requests and omits it from complete requests. The Business MUST include `line_items` in checkout responses.",
      "ucp_request": {
        "create": "optional",
        "update": "required",
        "complete": "omit"
      }
    },
    "cart_id": {
      "type": "string",
      "description": "Cart ID for checkout initialization, referencing an out-of-band cart mutually recognized by the Platform and Business. The Business MUST reject requests with an unsupported or unrecognized `cart_id`. Cart contents (`food_establishment`, `line_items`, `context`, `buyer`) take precedence over overlapping checkout fields; `food_establishment` and `line_items` may be omitted or empty.",
      "ucp_request": {
        "create": "optional",
        "update": "omit",
        "complete": "omit"
      },
      "ucp_response": "omit"
    },
    "buyer": {
      "$ref": "https://ucp.dev/draft/schemas/food/types/buyer.json",
      "description": "Representation of the buyer.",
      "ucp_request": {
        "create": "optional",
        "update": "optional",
        "complete": "omit"
      }
    },
    "context": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/context.json",
      "ucp_request": {
        "create": "optional",
        "update": "optional",
        "complete": "omit"
      }
    },
    "signals": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/signals.json",
      "ucp_request": "optional"
    },
    "status": {
      "type": "string",
      "enum": [
        "incomplete",
        "requires_escalation",
        "ready_for_complete",
        "complete_in_progress",
        "completed",
        "canceled"
      ],
      "description": "Checkout state indicating the current phase and required action. See Checkout Status lifecycle documentation for state transition details.",
      "ucp_request": "omit"
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency code reflecting the business's market determination. Derived from address, context, and geo IP—buyers provide signals, business determines currency.",
      "ucp_request": "omit"
    },
    "totals": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/totals.json",
      "description": "Different checkout totals.",
      "ucp_request": "omit"
    },
    "actions": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/actions.json",
      "description": "Outstanding extension-defined Actions for this checkout.",
      "ucp_request": "omit"
    },
    "messages": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/draft/schemas/common/types/message.json"
      },
      "description": "List of messages with error and info about the checkout session state.",
      "ucp_request": "omit"
    },
    "links": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/draft/schemas/common/types/link.json"
      },
      "description": "Links to be displayed by the platform (Privacy Policy, TOS). Mandatory for legal compliance.",
      "ucp_request": "omit"
    },
    "policies": {
      "type": "array",
      "items": {
        "$ref": "https://ucp.dev/draft/schemas/common/types/policy.json"
      },
      "description": "Policies (e.g., cancellation/refund terms) that apply to the items in this checkout. `applies_to` targets are relative to the response root; when absent or empty, refer to the URLs in `links[]`.",
      "ucp_request": "omit"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 expiry timestamp. Default TTL is 6 hours from creation if not sent.",
      "ucp_request": "omit"
    },
    "continue_url": {
      "type": "string",
      "format": "uri",
      "description": "URL for checkout handoff and session recovery. MUST be provided when status is requires_escalation. See specification for format and availability requirements.",
      "ucp_request": "omit"
    },
    "payment": {
      "$ref": "https://ucp.dev/draft/schemas/common/types/payment.json",
      "ucp_request": {
        "create": "optional",
        "update": "optional",
        "complete": "required"
      }
    },
    "order": {
      "$ref": "https://ucp.dev/draft/schemas/food/types/order_confirmation.json",
      "description": "Details about an order created for this checkout session.",
      "ucp_request": "omit"
    }
  },
  "version": "2026-11-13"
}