{
  "openapi": "3.0.1",
  "info": {
    "title": "Voucherify API - Validation Rules",
    "version": "v2018-08-01",
    "description": "Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details.",
    "contact": {
      "name": "Voucherify Team",
      "url": "https://www.voucherify.io/contact-support",
      "email": "support@voucherify.io"
    },
    "termsOfService": "https://www.voucherify.io/legal/subscription-agreement",
    "license": {
      "name": "MIT",
      "url": "https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE"
    }
  },
  "servers": [
    {
      "url": "https://{cluster}.voucherify.io",
      "description": "Base URL",
      "variables": {
        "cluster": {
          "default": "api",
          "enum": [
            "api",
            "us1.api",
            "as1.api",
            "download",
            "us1.download",
            "as1.download"
          ]
        }
      }
    }
  ],
  "paths": {
    "/v1/validation-rules": {
      "get": {
        "operationId": "list-validation-rules",
        "tags": [
          "Validation Rules"
        ],
        "summary": "List Validation Rules",
        "description": "Retrieve validation rules.",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterOrderListValidationRules"
            },
            "in": "query",
            "name": "order",
            "description": "This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash `-` preceding a sorting option means sorting in a descending order."
          },
          {
            "name": "start_date",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/ParameterDate"
            },
            "description": "Timestamp representing the date and time which results must start on. Represented in ISO 8601 format."
          },
          {
            "name": "end_date",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/ParameterDate"
            },
            "description": "Timestamp representing the date and time which results must end on. Represented in ISO 8601 format."
          }
        ],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Returns a dictionary of validation rules.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesListResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "object": "list",
                      "data_ref": "data",
                      "data": [
                        {
                          "id": "val_auLlxlfTR9Ps",
                          "name": "Customer in Segment",
                          "rules": {
                            "1": {
                              "name": "customer.segment",
                              "rules": {},
                              "property": null,
                              "conditions": {
                                "$is": [
                                  "seg_18tD3HR0h8ymPC07rBMLryk3"
                                ]
                              }
                            },
                            "logic": "1"
                          },
                          "applicable_to": {
                            "excluded": [],
                            "included": [],
                            "included_all": false
                          },
                          "created_at": "2021-12-10T11:08:16.499Z",
                          "updated_at": "2021-12-10T12:01:41.665Z",
                          "type": "advanced",
                          "context_type": "earning_rule.order.paid",
                          "assignments_count": 1,
                          "object": "validation_rules"
                        },
                        {
                          "id": "val_AvIe1WWuBXre",
                          "name": "Order Volume - Price of Any Item - = 1500 USD",
                          "rules": {
                            "1": {
                              "name": "order.items.price_any",
                              "rules": {},
                              "property": null,
                              "conditions": {
                                "$is": [
                                  150000
                                ]
                              }
                            },
                            "logic": "1"
                          },
                          "applicable_to": {
                            "excluded": [],
                            "included": [],
                            "included_all": false
                          },
                          "created_at": "2021-12-13T06:54:06.864Z",
                          "type": "advanced",
                          "context_type": "reward_assignment.pay_with_points",
                          "object": "validation_rules"
                        },
                        {
                          "id": "val_aZhPe4tQYMgr",
                          "name": "Business Validation Rule - excluded",
                          "rules": {
                            "logic": ""
                          },
                          "applicable_to": {
                            "excluded": [
                              {
                                "object": "products_collection",
                                "id": "pc_7fVU2RxybhR66YxC7r7BKKRh",
                                "source_id": null
                              },
                              {
                                "object": "sku",
                                "id": "sku_0bae3b28f610fd0da1",
                                "source_id": "first_product_sku_1"
                              }
                            ],
                            "included": [],
                            "included_all": true
                          },
                          "created_at": "2022-09-13T14:38:33.710Z",
                          "type": "basic",
                          "context_type": "campaign.discount_coupons.discount.apply_to_items_by_quantity",
                          "assignments_count": 1,
                          "object": "validation_rules"
                        },
                        {
                          "id": "val_bbJCAXAWtYX0",
                          "name": "Business Validation Rule - Test - Discount Effect - Amount - Items - each unit of matched product",
                          "rules": {
                            "logic": ""
                          },
                          "applicable_to": {
                            "excluded": [],
                            "included": [
                              {
                                "object": "products_collection",
                                "id": "pc_a11pr0dUc75",
                                "source_id": null,
                                "effect": "APPLY_TO_EVERY",
                                "quantity_limit": 1
                              }
                            ],
                            "included_all": false
                          },
                          "created_at": "2022-09-02T17:04:23.814Z",
                          "type": "basic",
                          "context_type": "campaign.discount_coupons.discount.apply_to_items_by_quantity",
                          "assignments_count": 1,
                          "object": "validation_rules"
                        },
                        {
                          "id": "val_BkV21MUJGaiT",
                          "name": "Order Volume -  Total Amount More than 100",
                          "rules": {
                            "1": {
                              "name": "order.amount",
                              "rules": {},
                              "property": null,
                              "conditions": {
                                "$more_than": [
                                  10000
                                ]
                              }
                            },
                            "logic": "1"
                          },
                          "applicable_to": {
                            "excluded": [],
                            "included": [],
                            "included_all": false
                          },
                          "created_at": "2021-12-10T14:01:10.750Z",
                          "type": "advanced",
                          "context_type": "reward_assignment.pay_with_points",
                          "object": "validation_rules"
                        },
                        {
                          "id": "val_BTQg027UGl0v",
                          "name": "Business Validation Rule - Get some $ off",
                          "rules": {
                            "logic": ""
                          },
                          "applicable_to": {
                            "excluded": [],
                            "included": [
                              {
                                "object": "product",
                                "id": "prod_0a41dd45dc85fcab40",
                                "source_id": "10474"
                              }
                            ],
                            "included_all": false
                          },
                          "created_at": "2021-12-07T06:58:23.759Z",
                          "updated_at": "2021-12-22T08:11:18.773Z",
                          "type": "advanced",
                          "context_type": "campaign.discount_coupons.discount.apply_to_items",
                          "assignments_count": 1,
                          "object": "validation_rules"
                        }
                      ],
                      "total": 6
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "create-validation-rules",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Create Validation Rules",
        "description": "Create a validation rule.\n<Warning>\n\n<Badge color=\"yellow\">Managing validation rules</Badge>\n\nIt is recommended to [create or update validation rules](/personalize/create-validation-rules) in the Voucherify dashboard. The rule builder in the dashboard helps configuring the desired conditions in a convenient way. The API should not be used as a preferable way to create and manage validation rules.\n\n</Warning>",
        "parameters": [],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRulesCreateRequestBody"
              },
              "examples": {
                "Example": {
                  "value": {
                    "name": "Set of Validation Rules",
                    "error": {
                      "message": "Your order does not meet at least one of the required criteria."
                    },
                    "applicable_to": {
                      "included_all": false,
                      "excluded": [
                        {
                          "object": "product",
                          "id": "prod_0bae45ffc7003ffc52",
                          "source_id": "second_product",
                          "effect": "APPLY_TO_EVERY"
                        }
                      ],
                      "included": [
                        {
                          "object": "product",
                          "id": "prod_0b72b00ffed198e344",
                          "source_id": null,
                          "effect": "APPLY_TO_MOST_EXPENSIVE",
                          "quantity_limit": 1
                        },
                        {
                          "object": "products_collection",
                          "id": "pc_4ndRXAsTOzwSdHcQcxf489uU",
                          "source_id": null,
                          "effect": "APPLY_TO_EVERY",
                          "quantity_limit": 5
                        }
                      ]
                    },
                    "rules": {
                      "1": {
                        "name": "order.metadata",
                        "property": "location",
                        "rules": {},
                        "conditions": {
                          "$is": [
                            "Santorini"
                          ]
                        },
                        "error": {
                          "message": "Your order must be placed at one of our Santorini shops."
                        }
                      },
                      "2": {
                        "name": "custom_event.metadata",
                        "property": "test",
                        "rules": {},
                        "conditions": {
                          "$greater_than_or_equal": [
                            1
                          ]
                        }
                      },
                      "3": {
                        "name": "order.items.every",
                        "rules": {
                          "1": {
                            "name": "order.items.metadata",
                            "property": "test",
                            "rules": {},
                            "conditions": {
                              "$greater_than_or_equal": [
                                1
                              ]
                            }
                          }
                        },
                        "conditions": {
                          "$is": [
                            {
                              "id": "<PROD_ID>",
                              "effect": "APPLY_TO_EVERY",
                              "object": "product",
                              "source_id": "<SOURCE_ID>"
                            }
                          ]
                        }
                      },
                      "logic": "1 or 2"
                    }
                  }
                }
              }
            }
          },
          "description": "Specify the validation rules parameters.",
          "required": true
        },
        "responses": {
          "200": {
            "description": "Returns a validation rule object.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesCreateResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "id": "val_eR1c41hu0vUU",
                      "name": "Business Validation Rule",
                      "rules": {
                        "1": {
                          "name": "string",
                          "property": "string",
                          "conditions": {
                            "$one_of_voucherify_conditions": [
                              "string"
                            ]
                          },
                          "rules": {
                            "1": {
                              "name": "string",
                              "property": "string",
                              "conditions": {},
                              "rules": {}
                            },
                            "logic": "string"
                          },
                          "error": {
                            "message": "string"
                          }
                        },
                        "logic": "(1 and 2) and (3)"
                      },
                      "error": {
                        "message": "string"
                      },
                      "applicable_to": {
                        "excluded": [
                          {
                            "object": "product",
                            "id": "string",
                            "source_id": "string",
                            "effect": "APPLY_TO_EVERY"
                          }
                        ],
                        "included": [
                          {
                            "object": "product",
                            "id": "string",
                            "source_id": "string",
                            "effect": "APPLY_TO_EVERY",
                            "quantity_limit": 0
                          }
                        ],
                        "included_all": true
                      },
                      "created_at": "2022-03-23T07:44:00.444Z",
                      "updated_at": "2022-04-26T08:35:54.960Z",
                      "type": "basic",
                      "context_type": "earning_rule.order.paid",
                      "object": "validation_rules"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Returns an error if the request parameters were not specified correctly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/e_400_invalid_validation_rules"
                },
                "examples": {
                  "Invalid Validation Rules": {
                    "value": {
                      "code": 400,
                      "key": "invalid_validation_rules",
                      "message": "Invalid Validation Rule Definition",
                      "details": "Rule 'custom_event.metadata' must have a 'property'"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/validation-rules/{validationRuleId}": {
      "parameters": [
        {
          "schema": {
            "$ref": "#/components/schemas/ParameterValidationRuleId"
          },
          "name": "validationRuleId",
          "in": "path",
          "required": true,
          "description": "A unique validation rule ID."
        }
      ],
      "get": {
        "operationId": "get-validation-rule",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Get Validation Rule",
        "description": "Retrieve the details of a validation rule.",
        "parameters": [],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the validation rule object.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesGetResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "id": "val_TU4de3EP4dlL",
                      "name": "Order is less than $40",
                      "rules": {
                        "1": {
                          "name": "order.amount",
                          "property": null,
                          "conditions": {
                            "$less_than": [
                              4000
                            ]
                          },
                          "rules": {}
                        },
                        "logic": "1"
                      },
                      "applicable_to": {
                        "excluded": [],
                        "included": [],
                        "included_all": false
                      },
                      "created_at": "2022-08-11T16:42:13.630Z",
                      "type": "advanced",
                      "context_type": "reward_assignment.pay_with_points",
                      "object": "validation_rules"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "update-validation-rule",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Update Validation Rule",
        "description": "Update validation rule parameters.\n<Warning>\n\n<Badge color=\"yellow\">Managing validation rules</Badge>\n\nIt is recommended to [create or update validation rules](/personalize/create-validation-rules) in the Voucherify dashboard. The rule builder in the dashboard helps configuring the desired conditions in a convenient way. The API should not be used as a preferable way to create and manage validation rules.\n\n</Warning>",
        "parameters": [],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "requestBody": {
          "description": "Specify the parameters to be updated.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRulesUpdateRequestBody"
              },
              "examples": {
                "Example": {
                  "value": {
                    "name": "Set of Validation Rules Updated",
                    "error": {
                      "message": "Your orders do not meet at least one of the required criteria."
                    },
                    "applicable_to": {
                      "included_all": false,
                      "excluded": [
                        {
                          "object": "product",
                          "id": "prod_0bae45ffc7003ffccc",
                          "source_id": "second_product",
                          "effect": "APPLY_TO_EVERY"
                        }
                      ],
                      "included": [
                        {
                          "object": "product",
                          "id": "prod_0b72b00ffed198e333",
                          "source_id": null,
                          "effect": "APPLY_TO_CHEAPEST",
                          "quantity_limit": 1
                        },
                        {
                          "object": "products_collection",
                          "id": "pc_4ndRXAsTOzwSdHcQcxf489uU",
                          "source_id": null,
                          "effect": "APPLY_TO_EVERY",
                          "quantity_limit": 5
                        }
                      ]
                    },
                    "rules": {
                      "1": {
                        "name": "order.metadata",
                        "property": "place",
                        "rules": {},
                        "conditions": {
                          "$is": [
                            "Santorini"
                          ]
                        },
                        "error": {
                          "message": "Your order must be placed at one of our Santorini shops on the beach."
                        }
                      },
                      "2": {
                        "name": "custom_event.metadata",
                        "property": "lining",
                        "rules": {},
                        "conditions": {
                          "$greater_than_or_equal": [
                            1
                          ]
                        }
                      },
                      "3": {
                        "name": "order.items.every",
                        "rules": {
                          "1": {
                            "name": "order.items.metadata",
                            "property": "test",
                            "rules": {},
                            "conditions": {
                              "$greater_than_or_equal": [
                                1
                              ]
                            }
                          }
                        },
                        "conditions": {
                          "$is": [
                            {
                              "id": "<PRODs_ID>",
                              "effect": "APPLY_TO_EVERY",
                              "object": "product",
                              "source_id": "<SOURCEs_ID>"
                            }
                          ]
                        }
                      },
                      "logic": "1 and 2"
                    }
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Returns the validation rule object with the updated parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesUpdateResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "id": "val_VZ91fqqtoVmw",
                      "name": "Set of Validation Rules Updated",
                      "rules": {
                        "1": {
                          "name": "order.metadata",
                          "property": "place",
                          "conditions": {
                            "$is": [
                              "Santorini"
                            ]
                          },
                          "rules": {},
                          "error": {
                            "message": "Your order must be placed at one of our Santorini shops on the beach."
                          }
                        },
                        "2": {
                          "name": "custom_event.metadata",
                          "property": "lining",
                          "conditions": {
                            "$greater_than_or_equal": [
                              1
                            ]
                          },
                          "rules": {}
                        },
                        "3": {
                          "name": "order.items.every",
                          "conditions": {
                            "$is": [
                              {
                                "id": "<PRODs_ID>",
                                "effect": "APPLY_TO_EVERY",
                                "object": "product",
                                "source_id": "<SOURCEs_ID>"
                              }
                            ]
                          },
                          "rules": {
                            "1": {
                              "name": "order.items.metadata",
                              "property": "test",
                              "conditions": {
                                "$greater_than_or_equal": [
                                  1
                                ]
                              },
                              "rules": {}
                            }
                          }
                        },
                        "logic": "1 and 2"
                      },
                      "error": {
                        "message": "Your orders do not meet at least one of the required criteria."
                      },
                      "applicable_to": {
                        "excluded": [
                          {
                            "object": "product",
                            "id": "prod_0bae45ffc7003ffccc",
                            "source_id": "second_product",
                            "effect": "APPLY_TO_EVERY"
                          }
                        ],
                        "included": [
                          {
                            "object": "product",
                            "id": "prod_0b72b00ffed198e333",
                            "source_id": null,
                            "effect": "APPLY_TO_CHEAPEST",
                            "quantity_limit": 1
                          },
                          {
                            "object": "products_collection",
                            "id": "pc_4ndRXAsTOzwSdHcQcxf489uU",
                            "source_id": null,
                            "effect": "APPLY_TO_EVERY",
                            "quantity_limit": 5
                          }
                        ],
                        "included_all": false
                      },
                      "created_at": "2022-09-14T05:54:51.099Z",
                      "updated_at": "2022-09-14T06:06:32.855Z",
                      "type": "complex",
                      "context_type": "global",
                      "object": "validation_rules"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete-validation-rules",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Delete Validation Rule",
        "description": "This method deletes a validation rule.",
        "parameters": [],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "responses": {
          "204": {
            "description": "Returns no content if deletion is successful."
          },
          "404": {
            "description": "Returns an error indicating that the validation rule with the given ID was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Validation Rule Not Found": {
                    "value": {
                      "code": 404,
                      "key": "not_found",
                      "message": "Resource not found",
                      "details": "Cannot find validation_rules with id val_TGN3rqZ8vEm",
                      "request_id": "v-0ae3b3436346b778be",
                      "resource_id": "val_TGN3rqZ8vEm",
                      "resource_type": "validation_rules"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/validation-rules-assignments": {
      "get": {
        "operationId": "list-validation-rules-assignments",
        "tags": [
          "Validation Rules"
        ],
        "summary": "List Validation Rules' Assignment(s)",
        "description": "List all validation rules' assignments or filter the results using the related object ID or the validation rule ID query parameters.",
        "parameters": [
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterString"
            },
            "in": "query",
            "name": "related_object_id",
            "description": "The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution."
          },
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterValidationRuleId"
            },
            "in": "query",
            "name": "rule",
            "description": "Validation rule ID."
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterString"
            },
            "in": "query",
            "description": "Sorts the results using one of the filtering options: `-created_at`, `created_at`, where the dash `-` preceding a sorting option means sorting in a descending order.",
            "name": "order"
          }
        ],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules-assignments"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Returns a dictionary with a data property that contains an array of validation rule assignments. Each entry in the array is a separate object. If no more validation rule assignments are available, the resulting array will be empty. The result can be narrowed down according to default filters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesAssignmentsListResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "object": "list",
                      "data_ref": "data",
                      "data": [
                        {
                          "id": "asgm_2S7Xm4dab4UvYAgm",
                          "rule_id": "val_5ix74ru7e",
                          "related_object_id": "camp_YDsFdX8TgFtT0RUuKEFyhqs3",
                          "related_object_type": "campaign",
                          "created_at": "2022-02-08T10:49:30.534Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_sFV4wEFvldwIvgfb",
                          "rule_id": "val_ZEZmA9oit8aU",
                          "related_object_id": "distr_9QKI02wqgjWyvZXeQkFEPmkkYe",
                          "related_object_type": "distribution",
                          "created_at": "2022-06-29T11:41:07.680Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_8xelF5R4zB8ue168",
                          "rule_id": "val_ggDODO6fakMs",
                          "related_object_id": "ern_xrRuGEV7EW0X8wtMaze3HOfw",
                          "related_object_type": "earning_rule",
                          "created_at": "2022-02-28T12:25:56.783Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_tZaqxeO8gP4q91jG",
                          "rule_id": "val_WB6ETAiFztw5",
                          "related_object_id": "promo_kJliy076IuJYtuYWSHE9fSuT",
                          "related_object_type": "promotion_tier",
                          "created_at": "2022-08-10T10:30:39.986Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_xTMHiyPGSz3rp5m2",
                          "rule_id": "val_2AxnWmW2ra6X",
                          "related_object_id": "rewa_m9hEAu10KsPcLhGXiHG85aY0",
                          "related_object_type": "reward_assignment",
                          "created_at": "2021-12-10T11:38:35.922Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_DhlDn54JwqVFJzR6",
                          "rule_id": "val_eR1c41hu0vUU",
                          "related_object_id": "v_XuF7icVlUcVpHsSY9nG7n7yJa5wx27Va",
                          "related_object_type": "voucher",
                          "created_at": "2022-03-23T07:50:31.068Z",
                          "object": "validation_rules_assignment"
                        }
                      ],
                      "total": 6
                    }
                  },
                  "No Assignments": {
                    "value": {
                      "object": "list",
                      "data_ref": "data",
                      "data": [],
                      "total": 0
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/validation-rules/{validationRuleId}/assignments": {
      "parameters": [
        {
          "schema": {
            "$ref": "#/components/schemas/ParameterValidationRuleId"
          },
          "name": "validationRuleId",
          "in": "path",
          "required": true,
          "description": "Unique validation rule ID."
        }
      ],
      "get": {
        "operationId": "list-validation-rule-assignments",
        "tags": [
          "Validation Rules"
        ],
        "summary": "List Validation Rule Assignments",
        "description": "Retrieve validation rule assignments for a specific validation rule.",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterOrderListValidationRuleAssignments"
            },
            "in": "query",
            "name": "order",
            "description": "This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash `-` preceding a sorting option means sorting in a descending order."
          }
        ],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Returns a dictionary of validation rule assignments.  If the validation rule ID provided in the path parameter cannot be found, the endpoint will return an empty `data` array and a total of `0`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesAssignmentsListResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "object": "list",
                      "data_ref": "data",
                      "data": [
                        {
                          "id": "asgm_74F7QZoYbUoljwQO",
                          "rule_id": "val_4j7DCRm2IS59",
                          "related_object_id": "v_MBOEmHelKwvykVZ8JcT4TE5Kla5IMJyc",
                          "related_object_type": "voucher",
                          "created_at": "2022-02-17T09:05:34.642Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_zzLBm8mIzGQStXl9",
                          "rule_id": "val_4j7DCRm2IS59",
                          "related_object_id": "v_JtWunK6jUo7X2qOFj0SyRHq4p9tgENlT",
                          "related_object_type": "voucher",
                          "created_at": "2022-02-17T08:18:15.085Z",
                          "object": "validation_rules_assignment"
                        },
                        {
                          "id": "asgm_JztMAws0e0Qx2Xy6",
                          "rule_id": "val_4j7DCRm2IS59",
                          "related_object_id": "camp_kjja4moiVB7hQKPGOT61026Z",
                          "related_object_type": "campaign",
                          "created_at": "2022-02-15T13:26:34.807Z",
                          "object": "validation_rules_assignment"
                        }
                      ],
                      "total": 3
                    }
                  },
                  "No Assignments": {
                    "value": {
                      "object": "list",
                      "data_ref": "data",
                      "data": [],
                      "total": 0
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "create-validation-rule-assignment",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Create Validation Rules Assignments",
        "description": "Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.",
        "parameters": [
          {
            "schema": {
              "$ref": "#/components/schemas/ParameterBoolean"
            },
            "in": "query",
            "description": "If this flag is set to `true`, the previous assignment with the same data will be deleted and a new one will be added.",
            "name": "force"
          }
        ],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "requestBody": {
          "description": "Specify the resource that you would like to assign the validation rule to.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRulesAssignmentsCreateRequestBody"
              },
              "examples": {
                "Voucher": {
                  "value": {
                    "related_object_type": "voucher",
                    "related_object_id": "{{voucherId}}"
                  }
                },
                "Campaign": {
                  "value": {
                    "related_object_type": "campaign",
                    "related_object_id": "{{campaignId}}"
                  }
                },
                "Distribution": {
                  "value": {
                    "related_object_type": "distribution",
                    "related_object_id": "{{distributionId}}"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Returns a validation rules assignment object.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationRulesAssignmentsCreateResponseBody"
                },
                "examples": {
                  "Example": {
                    "value": {
                      "id": "asgm_kPPiNW3smQLRMWiF",
                      "rule_id": "val_ZEZmA9oit8aU",
                      "related_object_id": "camp_Rv9EuIrkT08YEORb2pUMGSUo",
                      "related_object_type": "campaign",
                      "created_at": "2022-09-14T07:06:49.557Z",
                      "object": "validation_rules_assignment"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Returns an error if an duplicate assignment is found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Duplicate": {
                    "value": {
                      "code": 409,
                      "key": "duplicate_found",
                      "message": "Duplicated resource found",
                      "details": "Duplicated validation_rules_assignment exists with id asgm_ixJEwQbUv8hfPlhO",
                      "request_id": "v-0bb06fd1c3478dcb47",
                      "resource_id": "asgm_ixJEwQbUv8hfPlhO",
                      "resource_type": "validation_rules_assignment"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/validation-rules/{validationRuleId}/assignments/{assignmentId}": {
      "parameters": [
        {
          "schema": {
            "$ref": "#/components/schemas/ParameterValidationRuleId"
          },
          "name": "validationRuleId",
          "in": "path",
          "required": true,
          "description": "A unique validation rule ID."
        },
        {
          "schema": {
            "$ref": "#/components/schemas/ParameterRewardAssignmentId"
          },
          "name": "assignmentId",
          "in": "path",
          "required": true,
          "description": "A unique validation rule assignment ID."
        }
      ],
      "delete": {
        "operationId": "delete-validation-rule-assignment",
        "tags": [
          "Validation Rules"
        ],
        "summary": "Delete Validation Rule Assignment",
        "description": "This method deletes a validation rule assignment.",
        "parameters": [],
        "security": [
          {
            "X-App-Id": [],
            "X-App-Token": []
          },
          {
            "X-Voucherify-OAuth": [
              "api",
              "validation-rules"
            ]
          }
        ],
        "responses": {
          "204": {
            "description": "Returns no content if deletion is successful."
          },
          "404": {
            "description": "Returns an error indicating that the validation rule or validation rule assignment with given ID was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "Validation Rule Not Found": {
                    "value": {
                      "code": 404,
                      "key": "not_found",
                      "message": "Resource not found",
                      "details": "Cannot find validation_rules with id val_4j7DCRm2IS5",
                      "request_id": "v-0ae3b84bac0683f697",
                      "resource_id": "val_4j7DCRm2IS5",
                      "resource_type": "validation_rules"
                    }
                  },
                  "Validation Rule Assignment Not Found": {
                    "value": {
                      "code": 404,
                      "key": "not_found",
                      "message": "Resource not found",
                      "details": "Cannot find validation_rules_assignment with id asgm_tDN7MJNayjrf1wy",
                      "request_id": "v-0ae3b87eeb9027c916",
                      "resource_id": "asgm_tDN7MJNayjrf1wy",
                      "resource_type": "validation_rules_assignment"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/ParameterLimit"
        },
        "description": "Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items."
      },
      "page": {
        "name": "page",
        "in": "query",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/ParameterPage"
        },
        "description": "Which page of results to return. The lowest value is `1`."
      }
    },
    "schemas": {
      "ParameterOrderListValidationRules": {
        "type": "string",
        "enum": [
          "created_at",
          "-created_at",
          "updated_at",
          "-updated_at",
          "name",
          "-name"
        ]
      },
      "ParameterDate": {
        "type": "string",
        "example": "2023-12-22T10:13:06.487Z",
        "format": "date-time"
      },
      "ValidationRulesListResponseBody": {
        "description": "Response body schema for **GET** `v1/validation-rules`.",
        "type": "object",
        "title": "Validation Rules List Response Body",
        "properties": {
          "object": {
            "type": "string",
            "description": "The type of the object represented by JSON. This object stores information about validation rules.",
            "default": "list"
          },
          "data_ref": {
            "type": "string",
            "description": "Identifies the name of the attribute that contains the array of validation rules.",
            "default": "data"
          },
          "data": {
            "type": "array",
            "description": "An array of validation rules.",
            "items": {
              "$ref": "#/components/schemas/ValidationRule"
            }
          },
          "total": {
            "type": "integer",
            "description": "Total number of validation rules in the project."
          }
        },
        "required": [
          "object",
          "data_ref",
          "data",
          "total"
        ]
      },
      "ValidationRulesCreateRequestBody": {
        "title": "Validation Rules Create Request Body",
        "description": "Request body schema for **POST** `v1/validation-rules`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRuleBase"
          },
          {
            "type": "object",
            "required": [
              "name"
            ]
          }
        ]
      },
      "ValidationRulesCreateResponseBody": {
        "type": "object",
        "title": "Validation Rules Create Response Body",
        "description": "Response body schema for **POST** `v1/validation-rules`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRule"
          }
        ]
      },
      "e_400_invalid_validation_rules": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "description": "Error's HTTP status code.",
            "default": 400
          },
          "key": {
            "type": "string",
            "default": "invalid_validation_rules",
            "description": "Short string describing the kind of error which occurred."
          },
          "message": {
            "type": "string",
            "description": "A human-readable message providing a short description of the error."
          },
          "details": {
            "type": "string",
            "description": "A human-readable message providing more details about the error."
          }
        },
        "title": "Invalid Validation Rules",
        "description": "Error: Bad Request &rarr; Invalid Validation Rules"
      },
      "ValidationRulesGetResponseBody": {
        "type": "object",
        "title": "Validation Rules Get Response Body",
        "description": "Response body schema for **GET** `v1/validation-rules/{validationRuleId}`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRule"
          }
        ]
      },
      "ParameterValidationRuleId": {
        "type": "string",
        "example": "val_TU4de3EP4dlL"
      },
      "ValidationRulesUpdateRequestBody": {
        "title": "Validation Rules Update Request Body",
        "description": "Response body schema for **PUT** `v1/validation-rules/{validationRuleId}`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRuleBase"
          }
        ]
      },
      "ValidationRulesUpdateResponseBody": {
        "type": "object",
        "title": "Validation Rules Update Response Body",
        "description": "Response body schema for **PUT** `v1/validation-rules/{validationRuleId}`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRule"
          }
        ]
      },
      "Error": {
        "title": "Error Object",
        "type": "object",
        "description": "Error details",
        "properties": {
          "code": {
            "type": "integer",
            "description": "Error's HTTP status code."
          },
          "key": {
            "type": "string",
            "description": "Short string describing the kind of error which occurred."
          },
          "message": {
            "type": "string",
            "description": "A human-readable message providing a short description of the error."
          },
          "details": {
            "type": "string",
            "description": "A human-readable message providing more details about the error."
          },
          "request_id": {
            "type": "string",
            "example": "v-0a885062c80375740f",
            "description": "This ID is useful when troubleshooting and/or finding the root cause of an error response by our support team."
          },
          "resource_id": {
            "type": "string",
            "description": "Unique resource ID that can be used in another endpoint to get more details.",
            "example": "rf_0c5d710a87c8a31f86"
          },
          "resource_type": {
            "type": "string",
            "description": "The resource type.",
            "example": "voucher"
          },
          "error": {
            "type": "object",
            "description": "Includes additional information about the error.",
            "properties": {
              "message": {
                "type": "string",
                "description": "The message configured by the user in a validation rule."
              }
            }
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "ParameterString": {
        "type": "string"
      },
      "ValidationRulesAssignmentsListResponseBody": {
        "type": "object",
        "title": "Validation Rules Assignments List Response Body",
        "description": "Response body for **GET** `v1/validation-rules-assignments` and **GET** `v1/validation-rules/{validationRuleId}/assignments`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRuleAssignmentsList"
          }
        ]
      },
      "ParameterOrderListValidationRuleAssignments": {
        "type": "string",
        "enum": [
          "created_at",
          "-created_at"
        ]
      },
      "ParameterBoolean": {
        "type": "boolean"
      },
      "ValidationRulesAssignmentsCreateRequestBody": {
        "type": "object",
        "description": "Request body schema for **POST** `v1/validation-rules/{validationRuleId}/assignments`.",
        "title": "Create Validation Rule Assignments Request Body",
        "properties": {
          "related_object_type": {
            "type": "string",
            "description": "Defines the related object, e.g. `voucher`.",
            "default": "voucher",
            "enum": [
              "voucher",
              "promotion_tier",
              "campaign",
              "earning_rule",
              "distribution",
              "reward_assignment"
            ]
          },
          "related_object_id": {
            "type": "string",
            "description": "Unique related object ID assigned by Voucherify, e.g. `v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno` for a voucher."
          }
        }
      },
      "ValidationRulesAssignmentsCreateResponseBody": {
        "type": "object",
        "title": "Validation Rules Assignments Create Response Body",
        "description": "Response body for **POST** `v1/validation-rules/{validationRuleId}/assignments`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRuleAssignment"
          }
        ]
      },
      "ParameterRewardAssignmentId": {
        "type": "string",
        "example": "rewa_m9hEAu10KsPcLhGXiHG85aY0"
      },
      "ParameterLimit": {
        "type": "integer",
        "maximum": 100,
        "minimum": 1
      },
      "ParameterPage": {
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      },
      "ValidationRule": {
        "title": "Validation Rule",
        "allOf": [
          {
            "$ref": "#/components/schemas/ValidationRuleBase"
          },
          {
            "title": "Validation Rule",
            "type": "object",
            "description": "This is an object representing a response validation rule.",
            "properties": {
              "id": {
                "type": "string",
                "example": "val_eR1c41hu0vUU",
                "description": "Unique validation rule ID."
              },
              "created_at": {
                "type": "string",
                "example": "2022-03-23T07:44:00.444Z",
                "description": "Timestamp representing the date and time when the validation rule was created. The value is shown in the ISO 8601 format.",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "example": "2022-04-26T08:35:54.960Z",
                "description": "Timestamp representing the date and time when the validation rule was updated. The value is shown in the ISO 8601 format.",
                "format": "date-time"
              },
              "assignments_count": {
                "description": "The number of instances the validation rule has been assigned to different types of redeemables.",
                "type": "integer"
              },
              "object": {
                "type": "string",
                "default": "validation_rules",
                "description": "The type of the object represented by JSON. This object stores information about the validation rule."
              }
            },
            "required": [
              "id",
              "name",
              "rules",
              "applicable_to",
              "created_at",
              "type",
              "context_type",
              "object"
            ]
          }
        ]
      },
      "ValidationRuleBase": {
        "title": "Validation Rule Base",
        "type": "object",
        "description": "This is an object representing a request validation rule.",
        "properties": {
          "name": {
            "type": "string",
            "description": "Custom, unique name for set of validation rules.",
            "example": "Business Validation Rule"
          },
          "rules": {
            "$ref": "#/components/schemas/ValidationRuleRules"
          },
          "bundle_rules": {
            "$ref": "#/components/schemas/ValidationRuleBundleRules"
          },
          "error": {
            "type": "object",
            "description": "Contains the error message returned from API when validation / redemption fails to meet requirements of defined rules.",
            "properties": {
              "message": {
                "type": "string",
                "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rules."
              }
            }
          },
          "applicable_to": {
            "type": "object",
            "properties": {
              "excluded": {
                "type": "array",
                "description": "Defines which items are excluded from a discount.",
                "items": {
                  "$ref": "#/components/schemas/ApplicableTo"
                }
              },
              "included": {
                "type": "array",
                "description": "Defines which items are included in a discount.",
                "items": {
                  "$ref": "#/components/schemas/ApplicableTo"
                }
              },
              "included_all": {
                "type": "boolean",
                "description": "Indicates whether all items are included in the discount."
              }
            }
          },
          "type": {
            "type": "string",
            "enum": [
              "expression",
              "basic",
              "advanced",
              "complex"
            ],
            "default": "expression",
            "description": "Type of validation rule."
          },
          "context_type": {
            "type": "string",
            "default": "global",
            "enum": [
              "earning_rule.order.paid",
              "earning_rule.custom_event",
              "earning_rule.customer.segment.entered",
              "earning_rule.customer.tier.joined",
              "earning_rule.customer.tier.left",
              "earning_rule.customer.tier.upgraded",
              "earning_rule.customer.tier.downgraded",
              "earning_rule.customer.tier.prolonged",
              "campaign.discount_coupons",
              "campaign.discount_coupons.discount.apply_to_order",
              "campaign.discount_coupons.discount.apply_to_items",
              "campaign.discount_coupons.discount.apply_to_items_proportionally",
              "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity",
              "campaign.discount_coupons.discount.apply_to_items_by_quantity",
              "campaign.discount_coupons.discount.fixed.apply_to_items",
              "campaign.discount_coupons.discount.percent.apply_to_items",
              "campaign.gift_vouchers",
              "campaign.gift_vouchers.gift.apply_to_order",
              "campaign.gift_vouchers.gift.apply_to_items",
              "campaign.referral_program",
              "campaign.referral_program.discount.apply_to_order",
              "campaign.referral_program.discount.apply_to_items",
              "campaign.referral_program.discount.apply_to_items_proportionally",
              "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity",
              "campaign.referral_program.discount.apply_to_items_by_quantity",
              "campaign.referral_program.discount.fixed.apply_to_items",
              "campaign.referral_program.discount.percent.apply_to_items",
              "campaign.promotion",
              "campaign.promotion.discount.apply_to_order",
              "campaign.promotion.discount.apply_to_items",
              "campaign.promotion.discount.apply_to_items_proportionally",
              "campaign.promotion.discount.apply_to_items_proportionally_by_quantity",
              "campaign.promotion.discount.apply_to_items_by_quantity",
              "campaign.promotion.discount.fixed.apply_to_items",
              "campaign.promotion.discount.percent.apply_to_items",
              "campaign.loyalty_program",
              "voucher.discount_voucher",
              "voucher.discount_voucher.discount.apply_to_order",
              "voucher.discount_voucher.discount.apply_to_items",
              "voucher.discount_voucher.discount.apply_to_items_proportionally",
              "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity",
              "voucher.discount_voucher.discount.apply_to_items_by_quantity",
              "voucher.discount_voucher.discount.fixed.apply_to_items",
              "voucher.discount_voucher.discount.percent.apply_to_items",
              "voucher.gift_voucher",
              "voucher.gift_voucher.gift.apply_to_order",
              "voucher.gift_voucher.gift.apply_to_items",
              "voucher.loyalty_card",
              "distribution.custom_event",
              "distribution.order.paid",
              "distribution.order.created",
              "distribution.order.canceled",
              "distribution.order.updated",
              "reward_assignment.pay_with_points",
              "global"
            ],
            "description": "Validation rule context type.  \n\n| **Context Type** | **Definition** |\n|:---|:---|\n| earning_rule.order.paid |  |\n| earning_rule.custom_event |  |\n| earning_rule.customer.segment.entered |  |\n| campaign.discount_coupons |  |\n| campaign.discount_coupons.discount.apply_to_order |  |\n| campaign.discount_coupons.discount.apply_to_items |  |\n| campaign.discount_coupons.discount.apply_to_items_proportionally |  |\n| campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity |  |\n| campaign.discount_coupons.discount.fixed.apply_to_items |  |\n| campaign.gift_vouchers |  |\n| campaign.gift_vouchers.gift.apply_to_order |  |\n| campaign.gift_vouchers.gift.apply_to_items |  |\n| campaign.referral_program |  |\n| campaign.referral_program.discount.apply_to_order |  |\n| campaign.referral_program.discount.apply_to_items |  |\n| campaign.referral_program.discount.apply_to_items_proportionally |  |\n| campaign.referral_program.discount.apply_to_items_proportionally_by_quantity |  |\n| campaign.referral_program.discount.fixed.apply_to_items |  |\n| campaign.promotion |  |\n| campaign.promotion.discount.apply_to_order |  |\n| campaign.promotion.discount.apply_to_items |  |\n| campaign.promotion.discount.apply_to_items_proportionally |  |\n| campaign.promotion.discount.apply_to_items_proportionally_by_quantity |  |\n| campaign.promotion.discount.fixed.apply_to_items |  |\n| campaign.loyalty_program |  |\n| voucher.discount_voucher |  |\n| voucher.discount_voucher.discount.apply_to_order |  |\n| voucher.discount_voucher.discount.apply_to_items |  |\n| voucher.discount_voucher.discount.apply_to_items_proportionally |  |\n| voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity |  |\n| voucher.discount_voucher.discount.fixed.apply_to_items |  |\n| voucher.gift_voucher |  |\n| voucher.gift_voucher.gift.apply_to_order |  |\n| voucher.gift_voucher.gift.apply_to_items |  |\n| voucher.loyalty_card |  |\n| distribution.custom_event |  |\n| reward_assignment.pay_with_points |  |\n| global |  |"
          }
        }
      },
      "ValidationRuleAssignmentsList": {
        "type": "object",
        "description": "Validation Rule Assignments List",
        "title": "Validation Rule Assignments List",
        "properties": {
          "object": {
            "type": "string",
            "description": "The type of the object represented by JSON. This object stores information about validation rule assignments.",
            "default": "list"
          },
          "data_ref": {
            "type": "string",
            "description": "Identifies the name of the JSON property that contains the array of validation rule assignments.",
            "default": "data"
          },
          "data": {
            "type": "array",
            "description": "A dictionary that contains an array of validation rule assignments.",
            "items": {
              "$ref": "#/components/schemas/ValidationRuleAssignment"
            }
          },
          "total": {
            "type": "integer",
            "description": "Total number of validation rule assignments."
          }
        },
        "required": [
          "object",
          "data_ref",
          "data",
          "total"
        ]
      },
      "ValidationRuleAssignment": {
        "title": "Validation Rule Assignment",
        "type": "object",
        "description": "This is an object representing a validation rule assignment.",
        "properties": {
          "id": {
            "type": "string",
            "example": "asgm_74F7QZoYbUoljwQO",
            "description": "Validation rule assignment ID."
          },
          "rule_id": {
            "type": "string",
            "example": "val_4j7DCRm2IS59",
            "description": "Validation rule ID."
          },
          "related_object_id": {
            "type": "string",
            "example": "v_JtWunK6jUo7X2qOFj0SyRHq4p9tgENlT",
            "description": "The resource ID to which the validation rule was assigned."
          },
          "related_object_type": {
            "type": "string",
            "description": "The type of resource to which the validation rule was assigned.",
            "enum": [
              "voucher",
              "campaign",
              "earning_rule",
              "reward_assignment",
              "promotion_tier",
              "distribution"
            ]
          },
          "created_at": {
            "type": "string",
            "example": "2022-02-17T08:18:15.085Z",
            "description": "Timestamp representing the date and time when the validation rule assignment was created. The value is shown in the ISO 8601 format.",
            "format": "date-time"
          },
          "object": {
            "type": "string",
            "default": "validation_rules_assignment",
            "description": "The type of the object represented by the ID.",
            "enum": [
              "validation_rules_assignment"
            ]
          }
        },
        "required": [
          "id",
          "rule_id",
          "related_object_id",
          "related_object_type",
          "created_at",
          "object"
        ]
      },
      "ValidationRuleRules": {
        "title": "Validation Rule Rules",
        "type": "object",
        "description": "Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions.",
        "properties": {
          "logic": {
            "type": "string",
            "example": "(1 and 2) and (3)",
            "description": "Defines the logic between the rules."
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Contains the name of the validation rule.",
          "properties": {
            "name": {
              "type": "string",
              "description": "Voucherify's specific rule name. Read [Validation rule reference](/optimize/validation-rules-reference) to learn how specific rules work. The list of available names is provided below.  \n\n|**Type**|**Name** |\n---- | -----------|\n|**Customer** | customer.segment<br />customer.metadata* |\n|**Order** |order.amount<br />order.total_amount<br />order.initial_amount<br />order.items.count<br />order.items.price_any<br />order.items.price_each<br />order.items.metadata_any<br />order.items.metadata_each<br />order.metadata* |\n| **Campaign** | campaign.orders.amount_discounted<br />campaign.orders.amount<br />campaign.redemptions.count<br />campaign.redemptions.count.daily<br />campaign.redemptions.count.weekly<br />campaign.redemptions.count.monthly<br />campaign.redemptions.customers_count<br />campaign.redemptions.customers_count.daily<br />campaign.redemptions.customers_count.weekly<br />campaign.redemptions.customers_count.monthly |\n| **Redemption** |redemption.gift.amount<br />redemption.count.daily<br />redemption.count.weekly<br />redemption.count.monthly<br />redemption.count.per_customer<br />redemption.count.per_customer.daily<br />redemption.count.per_customer.weekly<br />redemption.count.per_customer.monthly<br />redemption.api_key<br />redemption.count.per_api_key<br />redemption.user.login<br />redemption.count.per_user<br />redemption.metadata<br />redemption.reward.pay_with_points.points_used |\n| **Product** | product.id<br />product.price<br />product.quantity<br />product.discount_applicable<br />product.metadata*<br />product.metadata.aggregated_quantity<br />product.metadata.aggregated_amount<br />product.metadata.discount_applicable<br />product.metadata.match_all |\n| **SKU** | sku.id<br />sku.price<br />sku.quantity<br />sku.discount_applicable |\n| **Publication** | publication.redeemable_by_linked_customer |\n| **Custom Event** | custom_event.metadata* |\n| **Order items** | order.items.every<br />order.items.any<br />order.items.none<br />order.items.cheapest<br />order.items.most_expensive | order.items.quantity<br />order.items.aggregated_quantity<br />order.items.price<br />order.items.aggregated_amount<br />order.items.metadata* |  \n\n\n\n*Requires the `property` field to be defined."
            },
            "property": {
              "type": "string",
              "nullable": true,
              "description": "Custom name for a metadata property associated with the condition to be satisfied. **Required** if the property `name` is any of the following: \n customer_metadata<br />custom_event_metadata<br />order_items_metadata<br />order_metadata<br />product_metadata<br />redemption_metadata"
            },
            "conditions": {
              "$ref": "#/components/schemas/ValidationRuleConditions"
            },
            "rules": {
              "$ref": "#/components/schemas/ValidationRuleRules01"
            },
            "error": {
              "type": "object",
              "description": "Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.",
              "properties": {
                "message": {
                  "type": "string",
                  "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rule."
                }
              }
            }
          }
        }
      },
      "ValidationRuleBundleRules": {
        "title": "Validation Rule Bundle Rules",
        "type": "object",
        "description": "Contains all the definitions for the bundle rules. It is a set of key value pairs representing the rules and logic between them. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions.\n\nWhile updating with the PUT method, you can pass `\"bundle_rules\": null` to delete the configuration; in the response, an empty object is then returned.",
        "properties": {
          "limit": {
            "type": "integer",
            "description": "Defines how many bundles can be identified in the order and the maximum multiplier of the discount per identified bundle. For example, if the order meets 3 bundles, but `limit: 2`, the discount will be multiplied by 2.",
            "nullable": true,
            "minimum": 1,
            "maximum": 100,
            "default": 1
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Contains the name of the bundle rule.",
          "properties": {
            "name": {
              "type": "string",
              "description": "Voucherify's specific bundle rule name. Currently, it is only `order.items.any`.",
              "enum": [
                "order.items.any"
              ]
            },
            "conditions": {
              "type": "object",
              "description": "Defines the conditions of the bundle rule. The order items in the customer's cart must meet the conditions. Because the rule concerns order items, the only permissible condition is `$is`.",
              "properties": {
                "$is": {
                  "type": "array",
                  "maxItems": 1,
                  "items": {
                    "type": "object",
                    "description": "",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Unique identifier of the product, SKU, or collection assigned by Voucherify."
                      },
                      "type": {
                        "type": "string",
                        "description": "Type of the order item. It can be a `product_or_sku` or `products_collection`",
                        "enum": [
                          "product_or_sku",
                          "products_collection"
                        ]
                      },
                      "object": {
                        "type": "string",
                        "description": "Object used in the bundle rule. It can be a `products_collection`, `product`, or `sku`.",
                        "enum": [
                          "products_collection",
                          "product",
                          "sku"
                        ]
                      }
                    },
                    "required": [
                      "id",
                      "type",
                      "object"
                    ]
                  }
                }
              }
            },
            "rules": {
              "properties": {
                "logic": {
                  "type": "string",
                  "example": "1",
                  "description": "Defines the logic between the sub-rules."
                }
              },
              "additionalProperties": {
                "type": "object",
                "description": "Contains the name of the validation sub-rule.",
                "maxProperties": 1,
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Voucherify's specific sub-rule name. Currently, it is only `order.items.aggregated_quantity`.",
                    "enum": [
                      "order.items.aggregated_quantity"
                    ]
                  },
                  "conditions": {
                    "type": "object",
                    "description": "Defines the conditions of the bundle rule. The quantity of order items in the customer's cart must meet the conditions.",
                    "properties": {
                      "$is": {
                        "type": "array",
                        "maxItems": 1,
                        "items": {
                          "type": "number",
                          "minimum": 1,
                          "description": "The quantity of units in the customer's order must be equal or higher than the defined number."
                        }
                      }
                    }
                  },
                  "rules": {
                    "type": "object",
                    "description": "An empty object."
                  }
                }
              }
            },
            "error": {
              "type": "object",
              "description": "**CURRENTLY UNSUPPORTED**. Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.",
              "properties": {
                "message": {
                  "type": "string",
                  "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rule."
                }
              }
            }
          }
        }
      },
      "ApplicableTo": {
        "title": "Applicable To",
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "product",
              "sku",
              "products_collection"
            ],
            "description": "This object stores information about the resource to which the discount is applicable."
          },
          "id": {
            "type": "string",
            "description": "Unique product collection, product, or SKU identifier assigned by Voucherify."
          },
          "source_id": {
            "type": "string",
            "description": "The source identifier from your inventory system."
          },
          "product_id": {
            "type": "string",
            "description": "Parent product's unique ID assigned by Voucherify."
          },
          "product_source_id": {
            "type": "string",
            "description": "Parent product's source ID from your inventory system."
          },
          "price": {
            "type": "number",
            "description": "New fixed price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 price is written as 1000. In case of the fixed price being calculated by the formula, i.e. the price_formula parameter is present in the fixed price definition, this value becomes the fallback value. Such that in a case where the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed price."
          },
          "price_formula": {
            "type": "number",
            "description": "Formula used to dynamically calculate the discounted price of an item."
          },
          "effect": {
            "description": "Defines how the discount is applied to the customer's order.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ApplicableToEffect"
              }
            ]
          },
          "quantity_limit": {
            "type": "integer",
            "description": "The maximum number of units allowed to be discounted per order line item."
          },
          "aggregated_quantity_limit": {
            "type": "integer",
            "description": "The maximum number of units allowed to be discounted combined across all matched order line items."
          },
          "amount_limit": {
            "type": "integer",
            "description": "Upper limit allowed to be applied as a discount per order line item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600."
          },
          "aggregated_amount_limit": {
            "type": "integer",
            "description": "Maximum discount amount per order. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount on the entire order is written as 600. This value is definable for the following discount effects:\n- `APPLY_TO_ITEMS` (each item subtotal is discounted equally)\n- `APPLY_TO_ITEMS_BY_QUANTITY` (each unit of matched products has the same discount value)"
          },
          "product_campaign_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units (product, SKU, collection) that all customers can receive in a given campaign. If a product is selected, the limit covers all discounts across all SKUs belonging to that product. If a product collection is selected, the limit covers all products/SKUs within the collection.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_campaign_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per campaign.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_customer_campaign_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units (product, SKU, collection) that one customer can receive in a given campaign.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_customer_campaign_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per customer in a campaign.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_campaign_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units of a given product in a collection that all customers can receive in a given campaign.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_campaign_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per campaign for a product in a collection.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_customer_campaign_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units of a given product in a collection that one customer can receive in a campaign.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_customer_campaign_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per customer for a product in a collection.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_promotion_tier_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units that all customers can receive in a promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_promotion_tier_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_customer_promotion_tier_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units that one customer can receive in a given promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_customer_promotion_tier_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per customer in a promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_promotion_tier_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units of a given product in a collection that all customers can receive in a given promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_promotion_tier_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per promotion tier for a product in a collection.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_customer_promotion_tier_quantity_limit": {
            "type": "integer",
            "description": "Limits the number of discounted item units of a given product in a collection that one customer can receive in a promotion tier.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "product_in_collection_customer_promotion_tier_quantity_limit_formula": {
            "type": "string",
            "description": "Formula used to dynamically calculate the maximum units per customer in a promotion tier for a product in a collection.\n\nThis limit is available on demand as part of campaign budget limits. Contact [Voucherify support](https://www.voucherify.io/contact-support) or your account manager to learn more."
          },
          "order_item_indices": {
            "type": "array",
            "description": "Lists which order lines are (not) covered by the discount. The order in the array is determined by the sequence of applied discounts, while the numbers correspond to the order lines sent in the `order` object in the request. The first order line is assigned `0`, the second order line is assigned `1`, and so on.",
            "items": {
              "type": "integer"
            }
          },
          "order_item_units": {
            "type": "array",
            "description": "Lists which units within order lines are covered by the discount. The order line items are listed according to sequence of applied discounts while the `index` corresponds to the order line sent in the `order` object in the request.",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "description": "Number assigned to the order line item in accordance with the order sent in the request.",
                  "minimum": 0
                },
                "units": {
                  "type": "array",
                  "description": "Numbers of units in the order line covered by the discount; e.g. `2, 5, 8` for 10 units with the setting `\"skip_initially\": 1`, `\"repeat\": 3`. The counting of units starts from `1`. The maximum quantity of all handled units is 1000. If the quantity of all order items exceeds 1000, this array is not returned, but `units_limit_exceeded: true`. However, the discount is calculated properly for all relevant units.",
                  "items": {
                    "type": "integer"
                  }
                },
                "units_limit_exceeded": {
                  "type": "boolean",
                  "description": "Returned as `true` only when the sum total of `quantity` of all order items exceeds 1000."
                }
              }
            }
          },
          "repeat": {
            "type": "integer",
            "description": "Determines the recurrence of the discount, e.g. `\"repeat\": 3` means that the discount is applied to every third item."
          },
          "skip_initially": {
            "type": "integer",
            "description": "Determines how many items are skipped before the discount is applied."
          },
          "target": {
            "type": "string",
            "description": "Determines to which kinds of objects the discount is applicable. `ITEM` includes products and SKUs. `UNIT` means particular units within an order line.",
            "enum": [
              "ITEM",
              "UNIT"
            ]
          }
        },
        "required": [
          "object",
          "id",
          "effect"
        ]
      },
      "ValidationRuleConditions": {
        "title": "Validation Rule Conditions",
        "type": "object",
        "description": "A set of key value pairs representing the condition name and value. The list of available conditions is provided below: \n\n| **Condition (key)** | **Definition**                                                | \n|---------------------|---------------------------------------------------------------|\n| `$is`                 | A property is a predefined value.                             |                           \n| `$is_not`             | A property is not a predefined value.                         |                           \n| `$in`                 | A property is one value of the values in a predefined list of values.   |                          \n|`$not_in`                 | A property is not one of the values in a predefined list of values.   |                          \n| `$less_than`          | A property is less than a predefined value. Can be also used with datetime.                  |                     \n| `$less_than_or_equal` | A property is less than or equal to a predefined value. Can be also used with datetime.       | \n| `$more_than`          | A property is more than a predefined value. Can be also used with datetime.                  | \n| `$more_than_or_equal` | A property is more than or equal to a predefined value. Can be also used with datetime.      | \n| `$starts_with`        | A property starts with the predefined sequence of characters. | \n| `$ends_with `         | A property ends with the predefined sequence of characters.   | \n| `$contains`           | A property contains the predefined sequence of characters.    | \n| `$timeframe`          | A property occurs within the time frame, i.e. every 1 day for 1 hour, e.g. `$timeframe: [\"2024-11-12T14:59:23.019Z;P1D;PT1H\"]`                                                       | \n| `$timeframe_absolute` | A property occurs between two dates and times, e.g. `2024-11-14T16:02:00.000Z;2024-11-28T16:02:00.000Z`                                                        | \n| `$timeframe_daily_hours` | A property occurs between selected hours on selected days of the week, e.g. `18:00;20:01;2,3`, where `0` equals Sunday, `1` equals Monday, `2` equals Tuesday, `3` equals Wednesday, `4` equals Thursday, `5` equals Friday, and `6` equals Saturday.                                                       | \n| `$dow`                | A property occurs within given days of the week, where `0` equals Sunday, `1` equals Monday, `2` equals Tuesday, `3` equals Wednesday, `4` equals Thursday, `5` equals Friday, and `6` equals Saturday.                                                        | \n| `$count`              | For array metadata; the property must have exactly the defined number of elements.                                                        | \n| `$count_more`         | For array metadata; the property must have more elements than the defined number.                                                        | \n| `$count_less`         | For array metadata; the property must have less elements than the defined number.                                                        | \n| `$from`               | The property must belong to the predefined value. Related to product collections and best used together with the `$is` condition.                                                        | \n | `$after`               | The value is after the date.                                                        | \n| `$before`               | The value is before the date.                                                        | \n| `$more_than_ago`               | The date is more than the defined value ago expressed in number of days, relative to today, e.g. more than 3 days ago.                                                        | \n| `$less_than_ago`               | The date is less than the defined value ago expressed in number of days, relative to today, less than 3 days ago.                                                        | \n| `is_days_ago`               | The date is exactly the defined value ago expressed in number of days, relative to today, e.g. exactly 3 days ago.                                                        | \n| `$more_than_future`               | The date is more than the defined value in the future expressed in number of days, relative to today, e.g. more than 3 days in the future.                                                        | \n| `$less_than_ago`               | The date is less than the defined value in the future expressed in number of days, relative to today, e.g. less than 3 days in the future.                                                        | \n| `$is_days_in_future`               | The date is exactly the defined value in the future expressed in number of days, relative to today, e.g. exactly 3 days in the future.                                                        | \n",
        "properties": {
          "$is": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$is_not": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$in": {
            "$ref": "#/components/schemas/Any"
          },
          "$not_in": {
            "$ref": "#/components/schemas/Any"
          },
          "$less_than": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$less_than_or_equal": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$more_than": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$more_than_or_equal": {
            "$ref": "#/components/schemas/AnyOne"
          },
          "$starts_with": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$ends_with": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$contains": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$timeframe": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$timeframe_absolute": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$timeframe_daily_hours": {
            "$ref": "#/components/schemas/AnyString"
          },
          "$dow": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0,
              "maximum": 6
            }
          },
          "$count": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$count_more": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$count_less": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$not_differ": {
            "$ref": "#/components/schemas/Any"
          },
          "$not_intersect": {
            "$ref": "#/components/schemas/Any"
          },
          "$from": {
            "$ref": "#/components/schemas/Any"
          },
          "$after": {
            "$ref": "#/components/schemas/AnyDateDateTime"
          },
          "$before": {
            "$ref": "#/components/schemas/AnyDateDateTime"
          },
          "$more_than_ago": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$less_than_ago": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$is_days_ago": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$more_than_future": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$less_than_future": {
            "$ref": "#/components/schemas/AnyNumber"
          },
          "$is_days_in_future": {
            "$ref": "#/components/schemas/AnyNumber"
          }
        }
      },
      "ValidationRuleRules01": {
        "title": "Validation Rule Rules",
        "type": "object",
        "description": "Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions.",
        "properties": {
          "logic": {
            "type": "string",
            "example": "(1 and 2) and (3)",
            "description": "Defines the logic between the rules."
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Contains the name of the validation rule.",
          "properties": {
            "name": {
              "type": "string",
              "description": "Voucherify's specific rule name. Read [Validation rule reference](/optimize/validation-rules-reference) to learn how specific rules work. The list of available names is provided below.  \n\n|**Type**|**Name** |\n---- | -----------|\n|**Customer** | customer.segment<br />customer.metadata* |\n|**Order** |order.amount<br />order.total_amount<br />order.initial_amount<br />order.items.count<br />order.items.price_any<br />order.items.price_each<br />order.items.metadata_any<br />order.items.metadata_each<br />order.metadata* |\n| **Campaign** | campaign.orders.amount_discounted<br />campaign.orders.amount<br />campaign.redemptions.count<br />campaign.redemptions.count.daily<br />campaign.redemptions.count.weekly<br />campaign.redemptions.count.monthly<br />campaign.redemptions.customers_count<br />campaign.redemptions.customers_count.daily<br />campaign.redemptions.customers_count.weekly<br />campaign.redemptions.customers_count.monthly |\n| **Redemption** |redemption.gift.amount<br />redemption.count.daily<br />redemption.count.weekly<br />redemption.count.monthly<br />redemption.count.per_customer<br />redemption.count.per_customer.daily<br />redemption.count.per_customer.weekly<br />redemption.count.per_customer.monthly<br />redemption.api_key<br />redemption.count.per_api_key<br />redemption.user.login<br />redemption.count.per_user<br />redemption.metadata<br />redemption.reward.pay_with_points.points_used |\n| **Product** | product.id<br />product.price<br />product.quantity<br />product.discount_applicable<br />product.metadata*<br />product.metadata.aggregated_quantity<br />product.metadata.aggregated_amount<br />product.metadata.discount_applicable<br />product.metadata.match_all |\n| **SKU** | sku.id<br />sku.price<br />sku.quantity<br />sku.discount_applicable |\n| **Publication** | publication.redeemable_by_linked_customer |\n| **Custom Event** | custom_event.metadata* |\n| **Order items** | order.items.every<br />order.items.any<br />order.items.none<br />order.items.cheapest<br />order.items.most_expensive | order.items.quantity<br />order.items.aggregated_quantity<br />order.items.price<br />order.items.aggregated_amount<br />order.items.metadata* |  \n\n\n\n*Requires the `property` field to be defined."
            },
            "property": {
              "type": "string",
              "nullable": true,
              "description": "Custom name for a metadata property associated with the condition to be satisfied. **Required** if the property `name` is any of the following: \n customer_metadata<br />custom_event_metadata<br />order_items_metadata<br />order_metadata<br />product_metadata<br />redemption_metadata"
            },
            "conditions": {
              "$ref": "#/components/schemas/ValidationRuleConditions"
            },
            "rules": {
              "$ref": "#/components/schemas/ValidationRuleRules02"
            },
            "error": {
              "type": "object",
              "description": "Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.",
              "properties": {
                "message": {
                  "type": "string",
                  "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rule."
                }
              }
            }
          }
        }
      },
      "ApplicableToEffect": {
        "title": "Applicable To Effect",
        "type": "string",
        "enum": [
          "APPLY_TO_EVERY",
          "APPLY_TO_CHEAPEST",
          "APPLY_FROM_CHEAPEST",
          "APPLY_TO_MOST_EXPENSIVE",
          "APPLY_FROM_MOST_EXPENSIVE"
        ]
      },
      "AnyOne": {
        "title": "Any",
        "type": "array",
        "items": {
          "oneOf": [
            {
              "title": "string",
              "type": "string"
            },
            {
              "title": "string - date",
              "type": "string",
              "format": "date"
            },
            {
              "title": "string - date-time",
              "type": "string",
              "format": "date-time"
            },
            {
              "title": "number",
              "type": "number"
            },
            {
              "title": "object",
              "type": "object"
            }
          ]
        },
        "maxItems": 1
      },
      "Any": {
        "title": "Any",
        "type": "array",
        "items": {
          "oneOf": [
            {
              "title": "string",
              "type": "string"
            },
            {
              "title": "string - date",
              "type": "string",
              "format": "date"
            },
            {
              "title": "string - date-time",
              "type": "string",
              "format": "date-time"
            },
            {
              "title": "number",
              "type": "number"
            },
            {
              "title": "object",
              "type": "object"
            }
          ]
        }
      },
      "AnyString": {
        "title": "Any String",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "AnyNumber": {
        "title": "Any Number",
        "type": "array",
        "items": {
          "type": "number",
          "minimum": 0
        },
        "maxItems": 1
      },
      "AnyDateDateTime": {
        "title": "Any Date and Date-Time",
        "type": "array",
        "items": {
          "oneOf": [
            {
              "type": "string",
              "title": "Date",
              "format": "date"
            },
            {
              "type": "string",
              "title": "Date-time",
              "format": "date-time"
            }
          ]
        },
        "maxItems": 1
      },
      "ValidationRuleRules02": {
        "title": "Validation Rule Rules",
        "type": "object",
        "description": "Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions.",
        "properties": {
          "logic": {
            "type": "string",
            "example": "(1 and 2) and (3)",
            "description": "Defines the logic between the rules."
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Contains the name of the validation rule.",
          "properties": {
            "name": {
              "type": "string",
              "description": "Voucherify's specific rule name. Read [Validation rule reference](/optimize/validation-rules-reference) to learn how specific rules work. The list of available names is provided below.  \n\n|**Type**|**Name** |\n---- | -----------|\n|**Customer** | customer.segment<br />customer.metadata* |\n|**Order** |order.amount<br />order.total_amount<br />order.initial_amount<br />order.items.count<br />order.items.price_any<br />order.items.price_each<br />order.items.metadata_any<br />order.items.metadata_each<br />order.metadata* |\n| **Campaign** | campaign.orders.amount_discounted<br />campaign.orders.amount<br />campaign.redemptions.count<br />campaign.redemptions.count.daily<br />campaign.redemptions.count.weekly<br />campaign.redemptions.count.monthly<br />campaign.redemptions.customers_count<br />campaign.redemptions.customers_count.daily<br />campaign.redemptions.customers_count.weekly<br />campaign.redemptions.customers_count.monthly |\n| **Redemption** |redemption.gift.amount<br />redemption.count.daily<br />redemption.count.weekly<br />redemption.count.monthly<br />redemption.count.per_customer<br />redemption.count.per_customer.daily<br />redemption.count.per_customer.weekly<br />redemption.count.per_customer.monthly<br />redemption.api_key<br />redemption.count.per_api_key<br />redemption.user.login<br />redemption.count.per_user<br />redemption.metadata<br />redemption.reward.pay_with_points.points_used |\n| **Product** | product.id<br />product.price<br />product.quantity<br />product.discount_applicable<br />product.metadata*<br />product.metadata.aggregated_quantity<br />product.metadata.aggregated_amount<br />product.metadata.discount_applicable<br />product.metadata.match_all |\n| **SKU** | sku.id<br />sku.price<br />sku.quantity<br />sku.discount_applicable |\n| **Publication** | publication.redeemable_by_linked_customer |\n| **Custom Event** | custom_event.metadata* |\n| **Order items** | order.items.every<br />order.items.any<br />order.items.none<br />order.items.cheapest<br />order.items.most_expensive | order.items.quantity<br />order.items.aggregated_quantity<br />order.items.price<br />order.items.aggregated_amount<br />order.items.metadata* |  \n\n\n\n*Requires the `property` field to be defined."
            },
            "property": {
              "type": "string",
              "nullable": true,
              "description": "Custom name for a metadata property associated with the condition to be satisfied. **Required** if the property `name` is any of the following: \n customer_metadata<br />custom_event_metadata<br />order_items_metadata<br />order_metadata<br />product_metadata<br />redemption_metadata"
            },
            "conditions": {
              "$ref": "#/components/schemas/ValidationRuleConditions"
            },
            "rules": {
              "$ref": "#/components/schemas/ValidationRuleRules03"
            },
            "error": {
              "type": "object",
              "description": "Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.",
              "properties": {
                "message": {
                  "type": "string",
                  "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rule."
                }
              }
            }
          }
        }
      },
      "ValidationRuleRules03": {
        "title": "Validation Rule Rules",
        "type": "object",
        "description": "Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions.",
        "properties": {
          "logic": {
            "type": "string",
            "example": "(1 and 2) and (3)",
            "description": "Defines the logic between the rules."
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Contains the name of the validation rule.",
          "properties": {
            "name": {
              "type": "string",
              "description": "Voucherify's specific rule name. Read [Validation rule reference](/optimize/validation-rules-reference) to learn how specific rules work. The list of available names is provided below.  \n\n|**Type**|**Name** |\n---- | -----------|\n|**Customer** | customer.segment<br />customer.metadata* |\n|**Order** |order.amount<br />order.total_amount<br />order.initial_amount<br />order.items.count<br />order.items.price_any<br />order.items.price_each<br />order.items.metadata_any<br />order.items.metadata_each<br />order.metadata* |\n| **Campaign** | campaign.orders.amount_discounted<br />campaign.orders.amount<br />campaign.redemptions.count<br />campaign.redemptions.count.daily<br />campaign.redemptions.count.weekly<br />campaign.redemptions.count.monthly<br />campaign.redemptions.customers_count<br />campaign.redemptions.customers_count.daily<br />campaign.redemptions.customers_count.weekly<br />campaign.redemptions.customers_count.monthly |\n| **Redemption** |redemption.gift.amount<br />redemption.count.daily<br />redemption.count.weekly<br />redemption.count.monthly<br />redemption.count.per_customer<br />redemption.count.per_customer.daily<br />redemption.count.per_customer.weekly<br />redemption.count.per_customer.monthly<br />redemption.api_key<br />redemption.count.per_api_key<br />redemption.user.login<br />redemption.count.per_user<br />redemption.metadata<br />redemption.reward.pay_with_points.points_used |\n| **Product** | product.id<br />product.price<br />product.quantity<br />product.discount_applicable<br />product.metadata*<br />product.metadata.aggregated_quantity<br />product.metadata.aggregated_amount<br />product.metadata.discount_applicable<br />product.metadata.match_all |\n| **SKU** | sku.id<br />sku.price<br />sku.quantity<br />sku.discount_applicable |\n| **Publication** | publication.redeemable_by_linked_customer |\n| **Custom Event** | custom_event.metadata* |\n| **Order items** | order.items.every<br />order.items.any<br />order.items.none<br />order.items.cheapest<br />order.items.most_expensive | order.items.quantity<br />order.items.aggregated_quantity<br />order.items.price<br />order.items.aggregated_amount<br />order.items.metadata* |  \n\n\n\n*Requires the `property` field to be defined."
            },
            "property": {
              "type": "string",
              "nullable": true,
              "description": "Custom name for a metadata property associated with the condition to be satisfied. **Required** if the property `name` is any of the following: \n customer_metadata<br />custom_event_metadata<br />order_items_metadata<br />order_metadata<br />product_metadata<br />redemption_metadata"
            },
            "conditions": {
              "$ref": "#/components/schemas/ValidationRuleConditions"
            },
            "rules": {
              "type": "object",
              "description": "Another set of validation rules. If you need to create complex rules with more nested rules, use the validation rule builder in the dashboard."
            },
            "error": {
              "type": "object",
              "description": "Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.",
              "properties": {
                "message": {
                  "type": "string",
                  "description": "The error message returned from API when validation / redemption fails to meet requirements of defined rule."
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "X-App-Id": {
        "type": "apiKey",
        "name": "X-App-Id",
        "in": "header"
      },
      "X-App-Token": {
        "type": "apiKey",
        "name": "X-App-Token",
        "in": "header"
      },
      "X-Voucherify-OAuth": {
        "type": "oauth2",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://api.voucherify.io/v1/oauth/token",
            "scopes": {
              "api": "Gives access to whole server-side API.",
              "vouchers": "Gives access to all endpoints and methods starting with `v1/vouchers`.",
              "client_api": "Gives access to whole client-side API.",
              "client_vouchers": "Gives access to all endpoints and methods starting with `/client/v1/vouchers`.",
              "promotions": "Gives access to all endpoints and methods starting with `/v1/promotions`.",
              "client_promotions": "Gives access to all endpoints and methods starting with `/client/v1/promotions`",
              "campaigns": "Gives access to all endpoints and methods starting with `v1/campaigns`.",
              "client_publish": "Gives access to all endpoints and methods starting with `/client/v1/publish`.",
              "exports": "Gives access to all endpoints and methods starting with `/v1/exports`.",
              "publications": "Gives access to all endpoints and methods starting with `/v1/publications`.",
              "client_validate": "Gives access to all endpoints and methods starting with `/client/v1/validate`.",
              "validations": "Gives access to all endpoints and methods starting with `/v1/validations`.",
              "client_validations": "Gives access to all endpoints and methods starting with `/client/v1/validations`.",
              "qualifications": "Gives access to all endpoints and methods starting with `/v1/qualifications`.",
              "client_qualifications": "Gives access to all endpoints and methods starting with `/client/v1/qualifications`.",
              "client_redeem": "Gives access to all endpoints and methods starting with `/client/v1/redeem",
              "redemptions": "Gives access to all endpoints and methods starting with `/v1/redemptions`.",
              "client_redemptions": "Gives access to all endpoints and methods starting with `/client/v1/redemptions`",
              "customers": "Gives access to all endpoints and methods starting with `/v1/customers`.",
              "client_customers": "Gives access to all endpoints and methods starting with `/client/v1/customers`.",
              "orders": "Gives access to all endpoints and methods starting with `/v1/orders`.",
              "products": "Gives access to all endpoints and methods starting with `/v1/products`.",
              "skus": "Gives access to all endpoints and methods starting with `/v1/SKUs`.",
              "validation-rules": "Gives access to all endpoints and methods starting with `/v1/validation-rules`.",
              "validation-rules-assignments": "Gives access to all endpoints and methods starting with `/v1/validation-rules-assignments",
              "segments": "Gives access to all endpoints and methods starting with `/v1/segments`.",
              "events": "Gives access to all endpoints and methods starting with `/v1/events`.",
              "client_events": "Gives access to all endpoints and methods starting with `client/v1/events`.",
              "rewards": "Gives access to all endpoints and methods starting with `/v1/rewards`.",
              "assets": "Gives access to all endpoints and methods starting with `/v1/assets`.",
              "task-results": "Gives access to all endpoints and methods starting with `/v1/task-results`.",
              "loyalties": "Gives access to all endpoints and methods starting with `/v1/loyalties`.",
              "client_consents": "Gives access to all endpoints and methods starting with `client/v1/consents`.",
              "consents": "Gives access to all endpoints and methods starting with `/v1/consents`.",
              "async-actions": "Gives access to all endpoints and methods starting with `/v1/async-actions`.",
              "product-collections": "Gives access to all endpoints and methods starting with `/v1/product-collections`.",
              "categories": "Gives access to all endpoints and methods starting with `/v1/categories`.",
              "metadata-schemas": "Gives access to all endpoints and methods starting with `/v1/metadata-schemas`.",
              "locations": "Gives access to all endpoints and methods starting with `/v1/locations`.",
              "referrals": "Gives access to all endpoints and methods starting with `/v1/referrals`.",
              "trash-bin": "Gives access to all endpoints and methods starting with `/v1/trash-bin`.",
              "templates": "Gives access to all endpoints and methods starting with `/v1/templates`."
            }
          }
        }
      }
    }
  }
}