{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/Inventory/v1/schema.json",
  "title": "Inventory",
  "description": "Inventory record for a Product at a given physical or logical location and channel, aligned with schema.org https://schema.org/inventoryLevel",
  "x-objectsgrid-jsonLd": false,
  "type": "object",
  "properties": {
    "id": {
      "description": "The unique identifier for Inventory. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for Inventory. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "Inventory"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This Inventory's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "url": {
      "description": "This Inventory URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "product": {
      "description": "URL of the Product this Inventory record is for",
      "x-objectsgrid-rangeIncludes": [
        "Product",
        "ProductGroup",
        "ProductModel"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "location": {
      "type": [
        "string",
        "null"
      ],
      "description": "Physical or logical inventory location. Optional for clients without a physical warehouse. Examples: 'global', 'default', 'virtual', 'supplier:acme', 'channel:online'.",
      "examples": [
        "global",
        "default",
        "virtual",
        "supplier:acme",
        "channel:online"
      ]
    },
    "channel": {
      "type": [
        "string",
        "null"
      ],
      "description": "Sales channel code (e.g. 'online', 'pos', 'b2b', 'marketplace:amazon')."
    },
    "availableQuantity": {
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ],
      "description": "On-hand, salable quantity (schema.org QuantitativeValue). Ignored if isInfinite = true."
    },
    "reservedQuantity": {
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ],
      "description": "Quantity reserved for open orders, not yet shipped."
    },
    "safetyStock": {
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ],
      "description": "Minimum buffer stock level before triggering alerts/replenishment."
    },
    "inboundQuantity": {
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ],
      "description": "Quantity on the way (inbound POs, transfers, etc.)."
    },
    "backorderQuantity": {
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ],
      "description": "Quantity promised but not yet available (backorders)."
    },
    "isInfinite": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "If true, inventory is considered unlimited / non-depleting (e.g. digital goods, made-to-order).",
      "default": false
    },
    "status": {
      "type": [
        "string",
        "null"
      ],
      "description": "High-level stock status derived from quantities and isInfinite.",
      "enum": [
        "AVAILABLE",
        "LOW_STOCK",
        "OUT_OF_STOCK",
        "DISCONTINUED",
        "INFINITE"
      ]
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    }
  },
  "required": [
    "product"
  ],
  "unevaluatedProperties": false
}
