{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/synchronity-app/json-schema/synchronity-app-ampscart-schema.json",
  "title": "AMPSCart",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/synchronity-app-openapi.yml#/components/schemas/AMPSCart",
  "type": "object",
  "required": [
    "cart_id",
    "site_id",
    "items",
    "subtotal",
    "total",
    "currency",
    "expires_at"
  ],
  "properties": {
    "cart_id": {
      "type": "string"
    },
    "site_id": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AMPSCartItem"
      }
    },
    "subtotal": {
      "$ref": "#/$defs/MonetaryAmount"
    },
    "discounts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AMPSDiscount"
      }
    },
    "total": {
      "$ref": "#/$defs/MonetaryAmount"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "checkout_mode": {
      "type": "string",
      "enum": [
        "redirect"
      ],
      "description": "Present when the store hosts checkout (e.g. Shopify): the client shows a 'Continue to checkout' handoff to checkout_url instead of a cart-stage shipping/payment flow."
    },
    "checkout_url": {
      "type": "string",
      "format": "uri",
      "description": "Hosted-checkout URL for redirect-mode stores."
    }
  },
  "$defs": {
    "AMPSCartItem": {
      "type": "object",
      "required": [
        "item_id",
        "product_id",
        "title",
        "quantity",
        "unit_price",
        "line_total"
      ],
      "properties": {
        "item_id": {
          "type": "string"
        },
        "product_id": {
          "type": "string"
        },
        "variant_id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "quantity": {
          "type": "integer",
          "minimum": 1
        },
        "unit_price": {
          "$ref": "#/$defs/MonetaryAmount"
        },
        "line_total": {
          "$ref": "#/$defs/MonetaryAmount"
        },
        "image_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Product image for the cart line."
        }
      }
    },
    "AMPSDiscount": {
      "type": "object",
      "required": [
        "code",
        "amount"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "amount": {
          "$ref": "#/$defs/MonetaryAmount"
        }
      }
    },
    "MonetaryAmount": {
      "type": "object",
      "required": [
        "amount",
        "currency"
      ],
      "properties": {
        "amount": {
          "type": "string",
          "pattern": "^\\d+\\.\\d{2}$",
          "description": "Decimal string with exactly 2 decimal places."
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$",
          "description": "ISO 4217 currency code."
        }
      }
    }
  }
}