{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lemmebuyit-com/json-schema/lemmebuyit-com-change-schema.json",
  "title": "Change",
  "description": "A single immutable event from the retail-events ledger. Mirrors the\n`retail_events` document read at `/v1/changes`. Enrichment fields\n(marketplace matches, computed discounts, resolved category/seller) are\n`nullable: true` because they are populated only when the underlying\nproduct/match data is available at read time. Internal sourcing and\ntracking fields are never serialized into this feed.\n",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lemmebuyit-com-openapi.yaml#/components/schemas/Change",
  "type": "object",
  "properties": {
    "event_id": {
      "type": "string",
      "description": "Stable immutable identity (ES _id)."
    },
    "event": {
      "type": "string",
      "description": "Event type.",
      "enum": [
        "price_changed",
        "restock",
        "out_of_stock",
        "seller_changed",
        "promotion_started",
        "promotion_ended",
        "clearance",
        "clearance_ended",
        "match_added",
        "match_removed",
        "match_changed"
      ]
    },
    "retailer_id": {
      "type": "string"
    },
    "sku": {
      "type": "string"
    },
    "source": {
      "type": "string",
      "enum": [
        "refresh",
        "ext_sighting",
        "live_lookup",
        "feed"
      ],
      "description": "Emitting lane (refresh, ext_sighting, live_lookup, feed)."
    },
    "ingest_seq_ms": {
      "type": "integer",
      "format": "int64",
      "description": "Pipeline-stamped monotonic sort key (ms)."
    },
    "observed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "changed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "current_price": {
      "type": [
        "number",
        "null"
      ]
    },
    "previous_price": {
      "type": [
        "number",
        "null"
      ]
    },
    "original_price": {
      "type": [
        "number",
        "null"
      ]
    },
    "drop_amount": {
      "type": [
        "number",
        "null"
      ]
    },
    "drop_percent": {
      "type": [
        "number",
        "null"
      ]
    },
    "computed_discount_amount": {
      "type": [
        "number",
        "null"
      ]
    },
    "computed_discount_percent": {
      "type": [
        "number",
        "null"
      ],
      "description": "Read-time markdown OFF THE LIST PRICE (original_price - current effective price, as a %), computed from the live product doc. This is the deal-quality signal (distinct from drop_percent, which is the refresh-to-refresh delta): filter it with min_discount_percent. The list and current-effective prices are coalesced per retailer from (original_price | compare_at_price | price) and (sale_price | final_price | current_price | price). null when the product doc is absent or is not a markdown."
    },
    "retailer_discount_percent": {
      "type": [
        "number",
        "null"
      ]
    },
    "on_sale": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "in_stock": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "stock_state": {
      "type": [
        "string",
        "null"
      ]
    },
    "clearance": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "deal_type": {
      "type": [
        "string",
        "null"
      ],
      "description": "Walmart clearance deal type on clearance events / Walmart price events.",
      "enum": [
        "clearance",
        "rollback",
        "reduced"
      ]
    },
    "sold_by": {
      "type": [
        "string",
        "null"
      ]
    },
    "seller_type": {
      "type": [
        "string",
        "null"
      ]
    },
    "category": {
      "type": [
        "string",
        "null"
      ]
    },
    "upc": {
      "type": [
        "string",
        "null"
      ]
    },
    "gtin": {
      "type": [
        "string",
        "null"
      ]
    },
    "has_marketplace_match": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "match_type": {
      "type": [
        "string",
        "null"
      ]
    },
    "match_confidence": {
      "type": [
        "string",
        "null"
      ],
      "description": "Empty, 'exact', or 'fuzzy' only.",
      "enum": [
        "",
        "exact",
        "fuzzy"
      ]
    },
    "matches": {
      "type": "array",
      "description": "Read-time-enriched marketplace matches. Always an array (never null).",
      "items": {
        "type": "object",
        "properties": {
          "asin": {
            "type": "string"
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "confidence": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "sales_rank": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Amazon sales rank for online-arbitrage scoring. Omitted when unknown (Amazon's -1 sentinel)."
          },
          "package_quantity": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Units per Amazon pack, for per-unit profit math."
          },
          "buy_box_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Amazon buy-box price (joined from the resolved UPC/ASIN mapping). Omitted when the mapping is unresolved."
          },
          "amazon_fees": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Estimated Amazon per-unit fee total. Omitted when not yet computed."
          }
        },
        "required": [
          "asin"
        ]
      }
    },
    "promotion_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Promotion identity. Present only on promotion_started / promotion_ended events."
    },
    "promotion_title": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable promotion title."
    },
    "coupon_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "Coupon code, if the promotion requires one."
    },
    "promotion_type": {
      "type": [
        "string",
        "null"
      ],
      "description": "Single primary promotion type (first of the full list on /v1/promotions)."
    },
    "promotion_ends_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Promotion end date/time."
    }
  },
  "required": [
    "event_id",
    "event",
    "retailer_id",
    "sku",
    "source",
    "ingest_seq_ms"
  ]
}