{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/adobe/json-schema/adobe-criteria-popularity-schema.json",
  "title": "CriteriaPopularity",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/adobe-target-recommendations-openapi.yml#/components/schemas/CriteriaPopularity",
  "allOf": [
    {
      "$ref": "#/$defs/CriteriaMin"
    },
    {
      "type": "object",
      "properties": {
        "aggregation": {
          "type": "string",
          "enum": [
            "NONE",
            "AGGREGATE",
            "ALL_OR_NOTHING"
          ],
          "default": "NONE",
          "description": "Whether recommendations should be shown solely based on the key (`NONE`) or visitor's behavioral history with\nrespect to the key (`AGGREGATE`, `ALL_OR_NOTHING`).\n  - `NONE` implies no aggregation, to only show recommendations for the given key.\n  - `AGGREGATE` begins with recommendations for the given key, top seller in this instance, then continues to next\n    top seller until the design is filled.\n  - `ALL_OR_NOTHING` is similar to aggregation but the aggregation only happens if the given key, most viewed item\n    in this instance, has enough recommendations to fill the design. If the key does not have enough\n    recommendations, next most viewed item is considered sequentially until the design is filled.\n"
        },
        "backupDisabled": {
          "type": "boolean",
          "default": false,
          "description": "Whether backup recommendations are disabled when criteria does not generate enough recommendations."
        },
        "backupInclusionFilteringEnabled": {
          "type": "boolean",
          "default": true,
          "description": "Whether inclusion rules on the criteria should be applied to backup recommendations."
        },
        "configuration": {
          "$ref": "#/$defs/CriteriaPopularityConfiguration"
        },
        "criteriaGroup": {
          "type": "string",
          "enum": [
            "POPULARITY"
          ],
          "readOnly": true
        },
        "daysCount": {
          "type": "string",
          "enum": [
            "ONE_DAY",
            "TWO_DAYS",
            "ONE_WEEK",
            "TWO_WEEKS",
            "ONE_MONTH",
            "TWO_MONTHS"
          ],
          "description": "Time range of historical visitor behavioral data to consider for generating recommendations.\n\nThis field can not be used together with `hoursCount`\n"
        },
        "hoursCount": {
          "type": "integer",
          "description": "Time range of historical visitor behavioral data to consider for generating recommendations.\n\nThis field can not be used together with `daysCount`. Only allowed value `6`\n"
        },
        "enableCaching": {
          "type": "boolean",
          "default": false,
          "deprecated": true,
          "readOnly": true
        },
        "excludePurchases": {
          "type": "boolean",
          "default": false,
          "description": "Whether items that were previously purchased by the visitor should be excluded from recommendations."
        },
        "key": {
          "type": "string",
          "description": "Recommendation key. Values:\n  - When type is `METRIC`, this is a required field. The value is the name of an Analytics report suite metric.\n  - When type is `SELLERS` or `VIEWED`, this field is only used when creating a top sellers by custom profile attribute/most\n    viewed by custom profile attribute criteria. When creating this criteria type, the value should be set to\n    `customProfileAttribute` and the profile attribute is set in configuration.\n"
        },
        "minInventory": {
          "type": "integer",
          "format": "int32",
          "minimum": 0,
          "description": "Minimum number of pieces needed in stock for an item to be considered for recommendaton."
        },
        "partialDesignAllowed": {
          "type": "boolean",
          "default": false,
          "description": "Whether design be shown when the number of recommendations are less than item slots in the design."
        },
        "type": {
          "type": "string",
          "enum": [
            "SELLERS",
            "VIEWED",
            "METRIC"
          ],
          "description": "Recommendation logic. Values:\n\n  - `SELLERS`: Top sellers.\n  - `VIEWED`: Most viewed items.\n  - `METRIC`: Considers Analytics product report suite for recommendations.\n"
        }
      },
      "required": [
        "type"
      ]
    }
  ],
  "$defs": {
    "AlgorithmRankingRule": {
      "type": "object",
      "properties": {
        "matcher": {
          "$ref": "#/$defs/Matcher"
        },
        "weighting": {
          "type": "integer",
          "format": "int32",
          "minimum": 0,
          "maximum": 4
        }
      }
    },
    "CriteriaConfiguration": {
      "type": "object",
      "properties": {
        "inclusionRules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/InclusionMatcher"
          },
          "maxItems": 1000,
          "description": "Filtering rules to narrow the items to be displayed as recommendations. Inclusion rules are conjunctive and all rules\nmust be met to include an item in a recommendation. [More info](https://marketing.adobe.com/resources/help/en_US/target/recs/t_create_new_algorithm.html).\n"
        },
        "priceRange": {
          "$ref": "#/$defs/CriteriaPriceRange"
        },
        "rankingRules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AlgorithmRankingRule"
          },
          "maxItems": 1000,
          "description": "Rules for attribute weighting. Attribute weighting can be used to \"nudge\" the algorithm so certain items are more\nlikely to be shown. [More info](https://marketing.adobe.com/resources/help/en_US/target/recs/t_create_new_algorithm.html).\n"
        }
      },
      "description": "Object containing inclusion rules, attribute weighting, price filter, and some more configuration options specific to the criteria group."
    },
    "CriteriaMin": {
      "type": "object",
      "properties": {
        "criteriaGroup": {
          "type": "string",
          "readOnly": true
        },
        "criteriaTitle": {
          "type": "string",
          "maxLength": 250,
          "description": "Displayed in the design using variable `$criteria.title`."
        },
        "id": {
          "type": "integer",
          "format": "int64",
          "readOnly": true
        },
        "name": {
          "type": "string",
          "maxLength": 250,
          "description": "Unique name of the criteria."
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "lastModifiersName": {
          "type": "string",
          "readOnly": true
        },
        "lastModifiersEmail": {
          "type": "string",
          "readOnly": true
        },
        "lastModified": {
          "type": "string",
          "readOnly": true,
          "format": "date-time",
          "description": "The time in UTC when the criteria was last modified."
        }
      },
      "required": [
        "name"
      ]
    },
    "CriteriaPopularityConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/CriteriaConfiguration"
        },
        {
          "type": "object",
          "properties": {
            "datasource": {
              "type": "string",
              "default": "mboxes",
              "description": "Behavioral data source can either be `mboxes` or a valid report suite. If type is `METRIC`, this field is required and value must be a valid report suite."
            },
            "grouping": {
              "type": "object",
              "properties": {
                "attributes": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 250,
                    "pattern": "^(profile\\.|user\\.).+"
                  },
                  "maxItems": 10,
                  "description": "Array of profile attributes."
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "HIERARCHICAL",
                    "SEQUENTIAL"
                  ]
                }
              },
              "description": "Not applicable for type `METRIC`. Grouping allows to narrow recommendations by profile attributes.",
              "required": [
                "attributes",
                "type"
              ]
            },
            "attribute": {
              "type": "string",
              "pattern": "^(profile\\.|user\\.).+",
              "description": "Applicable for type `SELLERS` or `VIEWED`. Required only for top sellers by custom profile attribute/most viewed by custom profile attribute\n(that is, when key is `customProfileAttribute`).\n\nThe custom profile attribute to be used as the basis for providing recommendations. The value should include the prefix `user.` or `profile.`.\n"
            },
            "groupByEntityAttribute": {
              "type": "string",
              "description": "Applicable for type `SELLERS` or `VIEWED`. Required only for top sellers by custom profile attribute/most viewed by custom profile attribute\n(that is, when key is `customProfileAttribute`).\n\nThe entity attribute whose value will be matched to the custom profile attribute, in order to provide the list of\ntop sellers/most viewed items among those items with a matching attribute value. The value should **not** include the prefix `entity.`.\n"
            }
          }
        }
      ]
    },
    "CriteriaPriceRange": {
      "type": "object",
      "properties": {
        "max": {
          "type": "number",
          "format": "double"
        },
        "min": {
          "type": "number",
          "format": "double"
        }
      },
      "description": "Price rule filter for items to be considered in recommendations."
    },
    "InclusionMatcher": {
      "type": "object",
      "properties": {
        "attribute": {
          "type": "string",
          "maxLength": 100
        },
        "highRange": {
          "type": "string"
        },
        "lowRange": {
          "type": "string"
        },
        "operation": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/SourceAttribute"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 250
          },
          "minItems": 1,
          "maxItems": 1000
        }
      },
      "required": [
        "attribute",
        "operation"
      ]
    },
    "Matcher": {
      "type": "object",
      "properties": {
        "attribute": {
          "type": "string",
          "maxLength": 100
        },
        "operation": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/SourceAttribute"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 250
          },
          "minItems": 1,
          "maxItems": 1000
        }
      },
      "required": [
        "attribute",
        "operation"
      ]
    },
    "SourceAttribute": {
      "type": "object",
      "properties": {
        "defaultValue": {
          "type": "string"
        },
        "excludeAllWhenEmpty": {
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "type"
      ]
    }
  }
}