{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/green-check-verified/main/json-schema/green-check-verified-inventory-schema.json",
  "title": "Inventory",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/green-check-verified-crb-inventory-api-openapi.yml#/components/schemas/Inventory",
  "properties": {
    "id": {
      "$ref": "#/$defs/UUID",
      "description": "The primary key in the record"
    },
    "crb_id": {
      "$ref": "#/$defs/UUID",
      "description": "ID of the CRB"
    },
    "pos_type": {
      "$ref": "#/$defs/FriendlyPosName",
      "description": "The PosType the inventory record is sourced from"
    },
    "product_id": {
      "$ref": "#/$defs/NullableUUID",
      "description": "The unique ID of the product, can be accessed with /product endpoints"
    },
    "name": {
      "type": "string",
      "description": "Name of the product"
    },
    "sku": {
      "type": [
        "string",
        "null"
      ],
      "description": "SKU for the product. May or may not be provided by the POS"
    },
    "barcode": {
      "type": [
        "string",
        "null"
      ],
      "description": "The tag from the track and trace system that uniquely identifies this product for tracking purposes. May or may not be provided by the POS"
    },
    "total_quantity": {
      "$ref": "#/$defs/PositiveDouble",
      "description": "Total inventory quantity on record across all locations"
    },
    "pos_updated_date": {
      "$ref": "#/$defs/NullableUtcDateTime",
      "description": "Timestamp reported by the pos for the last update to this record. May or may not be provided by the POS",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "pos_updated_date_local": {
      "$ref": "#/$defs/NullableLocalDateTime",
      "description": "CRB local timestamp reported by the pos for the last update to this record. May or may not be provided by the POS",
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[2][0][0-9]{2}[-]([0][0-9]|[1][0-2])[-]([0-2][0-9]|[3][0-1]\\s([0-1][0-9]|[2][0-3])[:][0-5][0-9][:][0-5][0-9]([.][0-9]{1,3})?"
    },
    "gc_created_date": {
      "$ref": "#/$defs/UtcDateTime",
      "description": "Timestamp for when this inventory record was processed by green check",
      "type": "string",
      "format": "date-time"
    },
    "gc_updated_date": {
      "$ref": "#/$defs/UtcDateTime",
      "type": "string",
      "format": "date-time"
    },
    "location_data": {
      "items": {
        "$ref": "#/$defs/LocationInventory"
      },
      "type": "array",
      "description": "Location specific quantities. Not all POS systems support location data."
    }
  },
  "required": [
    "id",
    "crb_id",
    "pos_type",
    "product_id",
    "name",
    "sku",
    "barcode",
    "total_quantity",
    "pos_updated_date",
    "pos_updated_date_local",
    "gc_created_date",
    "gc_updated_date"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "FriendlyPosName": {
      "type": "string",
      "enum": [
        "Alleaves",
        "Dutchie",
        "Dutchie Wholesale",
        "Cova",
        "Meadow",
        "MJ Freeway",
        "MJ Freeway Wholesale",
        "Greenbits",
        "GrowFlow",
        "GrowFlow Wholesale",
        "Portal42",
        "Metrc S2S",
        "Metrc S2S Wholesale",
        "Flourish",
        "Flourish Wholesale",
        "Flowhub",
        "BioTrack",
        "BioTrack Wholesale",
        "Treez",
        "Blaze",
        "Quickbooks",
        "Sage Intacct",
        "Canix",
        "Brytemap",
        "POSaBIT",
        "Proteus420",
        "IndicaOnline",
        "Sweed",
        "Weave",
        "Jane",
        "Manual Upload Wholesale",
        "Cova Test Account",
        "Leaf Logix Test Account",
        "BioTrack Test Account",
        "Mj Freeway Test Account",
        "Treez IO Test Account",
        "Green Bits Test Account",
        "Manual Upload Retail",
        "Not Configured",
        "Unsupported",
        "CRBMonitor",
        "Plaid"
      ]
    },
    "LocationInventory": {
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Location name"
        },
        "quantity": {
          "$ref": "#/$defs/PositiveInteger",
          "description": "Quantity of product within this location"
        },
        "location_id": {
          "$ref": "#/$defs/UUID",
          "description": "Id of the location"
        },
        "pos_location_type": {
          "type": [
            "string",
            "null"
          ],
          "description": "Type of location"
        }
      },
      "required": [
        "name",
        "quantity",
        "location_id",
        "pos_location_type"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "NullableLocalDateTime": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[2][0][0-9]{2}[-]([0][0-9]|[1][0-2])[-]([0-2][0-9]|[3][0-1])\\s([0-1][0-9]|[2][0-3])[:][0-5][0-9][:][0-5][0-9][.][0-9]{3}"
    },
    "NullableUUID": {
      "type": "string",
      "format": "uuid",
      "pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$"
    },
    "NullableUtcDateTime": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "PositiveDouble": {
      "type": "number",
      "format": "double",
      "minimum": 0
    },
    "PositiveInteger": {
      "type": "integer",
      "format": "int32",
      "minimum": 0
    },
    "UUID": {
      "type": "string",
      "format": "uuid",
      "pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$"
    },
    "UtcDateTime": {
      "type": "string",
      "format": "date-time"
    }
  }
}