Skip to main content
PUT
/
v1
/
validation-rules
/
{validationRuleId}
Update Validation Rule
curl --request PUT \
  --url https://{cluster}.voucherify.io/v1/validation-rules/{validationRuleId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-App-Id: <api-key>' \
  --header 'X-App-Token: <api-key>' \
  --data '{
  "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"
  }
}'
{
  "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"
}

Authorizations

X-App-Id
string
header
required
X-App-Token
string
header
required
Authorization
string
header
required

Path Parameters

validationRuleId
string
required
Example:

Body

application/json
name
string
Example:
rules
object
bundle_rules
object
error
object
applicable_to
object
type
enum<string>
default:expression
Available options:
expression,
basic,
advanced,
complex
context_type
enum<string>
default:global
Available options:
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

Response

200 - application/json
name
string
required
Example:
rules
object
required
applicable_to
object
required
type
enum<string>
default:expression
required
Available options:
expression,
basic,
advanced,
complex
context_type
enum<string>
default:global
required
Available options:
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
id
string
required
Example:
created_at
string<date-time>
required
Example:
object
string
default:validation_rules
required
bundle_rules
object
error
object
updated_at
string<date-time>
Example:
assignments_count
integer