Validation Rule Object

Data model description

AttributesDescriptionExample
id

Unique validation rule ID.

val_eR1c41hu0vUU

name

Custom, unique name for set of validation rules.

Business Validation Rule

rules

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 consequtively beginning from 1. The values are objects containing the rule conditions.

AttributesDescriptionExample
1

Defines the rule.

AttributesDescriptionExample
name

Voucherify specific rule name. The list of available names is provided below.

Name
Customer
customer.segment
customer.metadata
Order
order.amount
order.items.count
order.items.price_any
order.items.price_each
order.items.metadata_any
order.items.metadata_each
order.metadata
Campaign
campaign.orders.amount_discounted
campaign.orders.amount
campaign.redemptions.count
campaign.redemptions.count.daily
campaign.redemptions.count.monthly
campaign.redemptions.customers_count
campaign.redemptions.customers_count.daily
campaign.redemptions.customers_count.monthly
Redemption
redemption.gift.amount
redemption.count.daily
redemption.count.monthly
redemption.count.per_customer
redemption.count.per_customer.daily
redemption.count.per_customer.monthly
redemption.api_key
redemption.count.per_api_key
redemption.user.login
redemption.count.per_user
redemption.metadata
redemption.reward.pay_with_points.points_used
Product
product.id
product.price
product.quantity
product.discount_applicable
product.metadata
product.metadata.aggregated_quantity
product.metadata.aggregated_amount
product.metadata.discount_applicable
product.metadata.match_all
SKU
sku.id
sku.price
sku.quantity
sku.discount_applicable
Publication
publication.redeemable_by_linked_customer
Custom Event
custom_event.metadata
Order items
order.items.every
order.items.any
order.items.none
order.items.cheapest
order.items.most_expensive
order.items.quantity
order.items.aggregated_quantity
order.items.price
order.items.aggregated_amount
order.items.metadata

*Requires the property field to be defined.

property

Custom name for a metadata property associated with the condition to be satisfied. Required if the property name is any of the following:

Name
customer_metadata
custom_event_metadata
order_items_metadata
order_metadata
product_metadata
redemption_metadata
conditions

A set of key value pairs representing the condition name and value. The list of available conditions is provided below:

Condition (key)DefinitionDoes not support Types
$isA property is a predefined value.
$is_notA property is not a predefined value.
$inA property either one value in a predefined list of values.
$less_thanA property is less than a predefined value.boolean
$less_than_or_equalA property is less than or equal to a predefined value.boolean
$more_thanA property is more than a predefined value.boolean
$more_than_or_equalA property is more than or equal to a predefined value.boolean
$starts_withA property starts with the predefined sequence of characters.boolean, number
$ends_withA property ends with the predefined sequence of characters.boolean, number
$containsA property contains the predefined sequence of characters.boolean, number
$timeframeboolean, number
$dowboolean, string
$countboolean, string
$count_moreboolean, string
$count_lessboolean, string
AttributesDescriptionExample
$one_of_voucherify_conditions

Contains a set of conditions for the rule.

rules

Contains all the nested 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 consequtively beginning from 1. The values are objects containing the rule conditions.

AttributesDescriptionExample
1

Defines the nested rule.

AttributesDescriptionExample
name
property
conditions
rules
logic
error

Contains the error message returned from API when validation / redemption fails to meet requirements of defined rule.

AttributesDescriptionExample
message

The error message returned from API when validation / redemption fails to meet requirements of defined rule.

logic

Defines the logic between the rules.

(1 and 2) and (3)

error

Contains the error message returned from API when validation / redemption fails to meet requirements of defined rules.

AttributesDescriptionExample
message

The error message returned from API when validation / redemption fails to meet requirements of defined rules.

applicable_to
AttributesDescriptionExample
excluded

Defines which items are excluded from a discount.

Array of:
AttributesDescriptionExample
object

The type of object being excluded from the rule.

Available values: product, sku, products_collection
id

Unique product ID, SKU ID, product collection ID i.e. prod_0b72b00ffed198e344z, sku_0b7d7dfb090be5c619, pc_4ndRXAsTOzwSdHcQcxf489uU.

source_id
strict
effect

Discount effect for an excluded resource.

Available values: APPLY_TO_EVERY
included

Defines which items are included in a discount.

Array of:
AttributesDescriptionExample
object

The type of object being included in the rule.

Available values: product, sku, products_collection
id

Unique product ID, SKU ID, product collection ID i.e. prod_0b72b00ffed198e344z, sku_0b7d7dfb090be5c619, pc_4ndRXAsTOzwSdHcQcxf489uU.

source_id
strict
effect

Discount effect for an included resource.

Available values: APPLY_TO_EVERY, APPLY_TO_CHEAPEST, APPLY_TO_MOST_EXPENSIVE
quantity_limit

A limit on the number of units that at maximum can qualify for a discount. This property is present for an AMOUNT type discount when the effect is applied to ITEMS and each unit of matched products has the same discount value.

included_all

Indicates whether all items are included in the discount.

created_at

Timestamp representing the date and time when the validation rule was created in ISO 8601 format.

2022-03-23T07:44:00.444Z

updated_at

Timestamp representing the date and time when the validation rule was updated in ISO 8601 format.

2022-04-26T08:35:54.960Z

type

Type of validation rule.

Available values: basic, advanced, complex
context_type

Validation rule context type.

Context TypeDefinition
earning_rule.order.paid
earning_rule.custom_event
earning_rule.customer.segment.entered
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.fixed.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.fixed.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.fixed.apply_to_items
campaign.loyalty_program
campaign.lucky_draw
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.fixed.apply_to_items
voucher.gift_voucher
voucher.gift_voucher.gift.apply_to_order
voucher.gift_voucher.gift.apply_to_items
voucher.loyalty_card
voucher.lucky_draw_code
distribution.custom_event
reward_assignment.pay_with_points
global
Available values: earning_rule.order.paid, earning_rule.custom_event, earning_rule.customer.segment.entered, 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.fixed.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.fixed.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.fixed.apply_to_items, campaign.loyalty_program, campaign.lucky_draw, 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.fixed.apply_to_items, voucher.gift_voucher, voucher.gift_voucher.gift.apply_to_order, voucher.gift_voucher.gift.apply_to_items, voucher.loyalty_card, voucher.lucky_draw_code, distribution.custom_event, reward_assignment.pay_with_points, global
object

The type of object represented by JSON. This object stores information about the validation rule.

Language
URL
Click Try It! to start a request and see the response here!