{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://brevo.com/schemas/brevo/order.json",
  "title": "Brevo eCommerce Order",
  "description": "Represents an eCommerce order synced to the Brevo platform for revenue attribution, purchase behavior tracking, and automated marketing workflows.",
  "type": "object",
  "required": ["id", "email", "status", "amount", "products", "createdAt"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier of the order from the merchant's system.",
      "minLength": 1
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Email address of the customer who placed the order."
    },
    "status": {
      "type": "string",
      "description": "Current status of the order in the fulfillment workflow.",
      "enum": ["pending", "completed", "cancelled", "refunded", "shipped", "processing"]
    },
    "amount": {
      "type": "number",
      "description": "Total order amount including shipping, tax, and item prices.",
      "minimum": 0
    },
    "products": {
      "type": "array",
      "description": "List of products included in the order.",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/OrderProduct"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "UTC date-time when the order was created."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "UTC date-time when the order was last updated."
    },
    "coupons": {
      "type": "array",
      "description": "Coupon codes applied to the order.",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "OrderProduct": {
      "type": "object",
      "description": "Represents a product line item within an eCommerce order.",
      "required": ["productId", "quantity", "price"],
      "properties": {
        "productId": {
          "type": "string",
          "description": "Unique identifier of the product.",
          "minLength": 1
        },
        "quantity": {
          "type": "integer",
          "description": "Number of units of the product ordered.",
          "minimum": 1
        },
        "price": {
          "type": "number",
          "description": "Unit price of the product at the time of the order.",
          "minimum": 0
        },
        "variantId": {
          "type": "string",
          "description": "Variant identifier if the product has size, color, or other variants."
        }
      }
    },
    "Product": {
      "type": "object",
      "description": "Represents a product in the Brevo eCommerce catalog.",
      "required": ["id", "name", "url"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier of the product.",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "description": "Name of the product.",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "URL of the product page on the merchant's website."
        },
        "imageUrl": {
          "type": "string",
          "format": "uri",
          "description": "URL of the product image."
        },
        "sku": {
          "type": "string",
          "description": "Stock keeping unit identifier for inventory tracking."
        },
        "price": {
          "type": "number",
          "description": "Current price of the product.",
          "minimum": 0
        },
        "categories": {
          "type": "array",
          "description": "IDs of categories the product belongs to.",
          "items": {
            "type": "string"
          }
        },
        "metaInfo": {
          "type": "object",
          "description": "Additional metadata about the product as key-value pairs.",
          "additionalProperties": true
        }
      }
    },
    "Category": {
      "type": "object",
      "description": "Represents a product category in the Brevo eCommerce catalog.",
      "required": ["id", "name"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier of the category.",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "description": "Name of the category.",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "URL of the category page on the merchant's website."
        }
      }
    }
  }
}
