{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/adobe/json-schema/adobe-criteria-custom-schema.json",
  "title": "CriteriaCustom",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/adobe-target-recommendations-openapi.yml#/components/schemas/CriteriaCustom",
  "allOf": [
    {
      "$ref": "#/$defs/CriteriaMin"
    },
    {
      "type": "object",
      "properties": {
        "backupDisabled": {
          "type": "boolean",
          "default": false,
          "description": "Whether backup recommendations are disabled when enough recommendations from CSV feed are not applicable in design."
        },
        "backupInclusionFilteringEnabled": {
          "type": "boolean",
          "default": true,
          "description": "Whether inclusion rules on the criteria should be applied to backup recommendations."
        },
        "configuration": {
          "$ref": "#/$defs/CriteriaCustomConfiguration"
        },
        "criteriaGroup": {
          "type": "string",
          "enum": [
            "CUSTOM"
          ],
          "readOnly": true
        },
        "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",
          "enum": [
            "CURRENT",
            "LAST_VIEWED",
            "LAST_PURCHASED",
            "MOST_VIEWED",
            "CURRENT_CATEGORY",
            "FAVORITE_CATEGORY",
            "PROFILE_ATTRIBUTE"
          ],
          "description": "Recommendation key. Values:\n\n- `CURRENT`: The currently viewed item.\n- `LAST_VIEWED`: The last viewed item.\n- `LAST_PURCHASED`: The last purchased item.\n- `MOST_VIEWED`: The most viewed item. The recommendations are determined by items that have been most viewed.\n  The score is determined by recency/frequency: 10 points for first item view, 5 points for every subsequent view,\n  all points are halved after the session ends.\n- `CURRENT_CATEGORY`: The category of the currently viewed item.\n- `FAVORITE_CATEGORY`: The category among visitor's categories with highest score. The recommendations are\n  determined by the categories that have been most viewed. The score is determined by recency/frequency: 10 points\n  for first category view, 5 points for every subsequent view.\n- `PROFILE_ATTRIBUTE`: Profile attribute.\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."
        }
      },
      "required": [
        "key",
        "configuration"
      ]
    }
  ],
  "$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."
    },
    "CriteriaCustomConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/CriteriaConfiguration"
        },
        {
          "type": "object",
          "properties": {
            "attribute": {
              "type": "string",
              "pattern": "^(profile\\.|user\\.).+",
              "description": "Applicable only when key is `PROFILE_ATTRIBUTE`. This is the profile attribute."
            },
            "feed": {
              "type": "object",
              "properties": {
                "connection": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "url",
                        "ftp"
                      ],
                      "description": "Protocol supported by the feed: HTTP or FTP"
                    },
                    "attributes": {
                      "oneOf": [
                        {
                          "$ref": "#/$defs/UrlFeedConnectionType"
                        },
                        {
                          "$ref": "#/$defs/FtpFeedConnectionType"
                        }
                      ]
                    }
                  },
                  "required": [
                    "type",
                    "attributes"
                  ],
                  "description": "Object containing feed connection details."
                },
                "environmentId": {
                  "type": "integer",
                  "format": "int32",
                  "description": "Identifier of a valid environment. Use `-1` for all environments."
                },
                "scheduleTime": {
                  "type": "string",
                  "pattern": "^([0-1][0-9]|2[0-3]):([0-5][0-9])$",
                  "description": "Scheduled time to run the feed. Format is `HH:mm`."
                },
                "scheduleType": {
                  "type": "string",
                  "enum": [
                    "daily",
                    "weekly",
                    "biWeekly",
                    "never"
                  ],
                  "description": "Feeds can be scheduled to be run at a given frequency."
                },
                "uploadHistory": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "status": {
                        "type": "string",
                        "enum": [
                          "SUCCESS",
                          "UNKNOWN_ERROR",
                          "PARSING_ERROR",
                          "SERVER_NOT_FOUND",
                          "CREDENTIALS_ERROR",
                          "DIRECTORY_NOT_FOUND",
                          "FILE_NOT_FOUND",
                          "SAINT_REPORT_NOT_FOUND",
                          "CLASSIFICATION_NOT_FOUND",
                          "SCHEDULED",
                          "DOWNLOADING_FEED_FILE",
                          "IMPORTING",
                          "FLUSHING_RESULTS",
                          "FLUSH_FAILED"
                        ]
                      },
                      "message": {
                        "type": "string"
                      },
                      "date": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  },
                  "required": [
                    "status",
                    "message",
                    "date"
                  ],
                  "readOnly": true,
                  "description": "Feed upload history."
                }
              },
              "required": [
                "connection",
                "environmentId",
                "scheduleType"
              ]
            }
          },
          "required": [
            "feed"
          ]
        }
      ]
    },
    "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"
      ]
    },
    "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."
    },
    "FtpFeedConnectionType": {
      "type": "object",
      "properties": {
        "SERVER": {
          "type": "string"
        },
        "USERNAME": {
          "type": "string"
        },
        "PASSWORD": {
          "type": "string"
        },
        "FILENAME": {
          "type": "string"
        },
        "DIRECTORY": {
          "type": "string"
        }
      },
      "required": [
        "SERVER",
        "USERNAME",
        "PASSWORD",
        "FILENAME",
        "DIRECTORY"
      ],
      "description": "FTP connection details of the feed."
    },
    "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"
      ]
    },
    "UrlFeedConnectionType": {
      "type": "object",
      "properties": {
        "URL": {
          "type": "string"
        }
      },
      "required": [
        "URL"
      ],
      "description": "HTTP location of the feed."
    }
  }
}