Validation Rule Object

Validation Rule

All of:

  1. Validation Rule Base
  2. Validation Rule

    AttributesDescription
    id
    string

    Unique validation rule ID.

    Example:

    val_eR1c41hu0vUU

    created_at
    string

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

    Example:

    2022-03-23T07:44:00.444Z

    updated_at
    string

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

    Example:

    2022-04-26T08:35:54.960Z

    assignments_count
    integer

    The number of instances the validation rule has been assigned to different types of redeemables.

    object
    string

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

Validation Rule Base

AttributesDescription
name
string

Custom, unique name for set of validation rules.

Example:

Business Validation Rule

rulesSee: Validation Rule Rules
error
object

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

AttributesDescription
message
string

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

applicable_to
object
AttributesDescription
excluded
array

Defines which items are excluded from a discount.

Array of Applicable To
included
array

Defines which items are included in a discount.

Array of Applicable To
included_all
boolean

Indicates whether all items are included in the discount.

type
string

Type of validation rule.

Available values: expression, basic, advanced, complex
context_type
string

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
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
distribution.custom_event
reward_assignment.pay_with_points
global
Available values: 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

Validation Rule Rules

AttributesDescription
logic
string

Defines the logic between the rules.

Example:

(1 and 2) and (3)

[propertyName]
object

Contains the name of the validation rule.

AttributesDescription
name
string

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

TypeName
Customercustomer.segment
customer.metadata
Orderorder.amount
order.initial_amount
order.items.count
order.items.price_any
order.items.price_each
order.items.metadata_any
order.items.metadata_each
order.metadata
Campaigncampaign.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
Redemptionredemption.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
Productproduct.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
SKUsku.id
sku.price
sku.quantity
sku.discount_applicable
Publicationpublication.redeemable_by_linked_customer
Custom Eventcustom_event.metadata
Order itemsorder.items.every
order.items.any
order.items.none
order.items.cheapest
order.items.most_expensive

*Requires the property field to be defined.

property
string, null

Custom name for a metadata property associated with the condition to be satisfied. Required if the property name is any of the following:
customer_metadata
custom_event_metadata
order_items_metadata
order_metadata
product_metadata
redemption_metadata

conditionsSee: Validation Rule Conditions
rulesSee: Validation Rule Rules
error
object

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

AttributesDescription
message
string

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

Applicable To

AttributesDescription
object
string

This object stores information about the resource to which the discount is applicable.

Available values: product, sku, products_collection
id
string

Unique product collection, product, or SKU identifier assigned by Voucherify.

source_id
string

The source identifier from your inventory system.

product_id
string

Parent product's unique ID assigned by Voucherify.

product_source_id
string

Parent product's source ID from your inventory system.

strict
boolean
price
number

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
number

Formula used to calculate the discounted price of an item.

effect

Defines how the discount is applied to the customer's order.

Applicable To Effect
quantity_limit
integer

The maximum number of units allowed to be discounted per order line item.

aggregated_quantity_limit
integer

The maximum number of units allowed to be discounted combined across all matched order line items.

amount_limit
integer

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
integer

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:

  • APPLY_TO_ITEMS (each item subtotal is discounted equally)
  • APPLY_TO_ITEMS_BY_QUANTITY (each unit of matched products has the same discount value)
order_item_indices
array

Determines the order in which the discount is applied to the products or SKUs sent in the order object in the request. The counting begins from 0.

repeat
integer

Determines the recurrence of the discount, e.g. "repeat": 3 means that the discount is applied to every third item.

skip_initially
integer

Determines how many items are skipped before the discount is applied.

target
string

Determines to which kinds of objects the discount is applicable. "ITEM" includes products and SKUs.

Available values: ITEM

Validation Rule Conditions

AttributesDescription
$isSee: Any
$is_notSee: Any
$inSee: Any
$not_inSee: Any
$less_thanSee: Any
$less_than_or_equalSee: Any
$more_than
array
$more_than_or_equalSee: Any
$starts_withSee: Any
$ends_withSee: Any
$containsSee: Any
$timeframeSee: Any
$timeframe_absoluteSee: Any
$dowSee: Any
$countSee: Any
$count_moreSee: Any
$count_lessSee: Any
$fromSee: Any
$not_differ
array
Array any of: string, number, object
$not_intersect
array
Array any of: string, number, object

Validation Rule Rules

AttributesDescription
logic
string

Defines the logic between the rules.

Example:

(1 and 2) and (3)

[propertyName]
object

Contains the name of the validation rule.

AttributesDescription
name
string

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

TypeName
Customercustomer.segment
customer.metadata
Orderorder.amount
order.initial_amount
order.items.count
order.items.price_any
order.items.price_each
order.items.metadata_any
order.items.metadata_each
order.metadata
Campaigncampaign.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
Redemptionredemption.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
Productproduct.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
SKUsku.id
sku.price
sku.quantity
sku.discount_applicable
Publicationpublication.redeemable_by_linked_customer
Custom Eventcustom_event.metadata
Order itemsorder.items.every
order.items.any
order.items.none
order.items.cheapest
order.items.most_expensive

*Requires the property field to be defined.

property
string, null

Custom name for a metadata property associated with the condition to be satisfied. Required if the property name is any of the following:
customer_metadata
custom_event_metadata
order_items_metadata
order_metadata
product_metadata
redemption_metadata

conditionsSee: Validation Rule Conditions
rulesSee: Validation Rule Rules
error
object

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

AttributesDescription
message
string

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

Applicable To Effect

Available values: APPLY_TO_EVERY, APPLY_TO_CHEAPEST, APPLY_FROM_CHEAPEST, APPLY_TO_MOST_EXPENSIVE, APPLY_FROM_MOST_EXPENSIVE

Any

One of:

  1. Array any of: string, number, object
  2. string
  3. number
  4. object

Validation Rule Rules

AttributesDescription
logic
string

Defines the logic between the rules.

Example:

(1 and 2) and (3)

[propertyName]
object

Contains the name of the validation rule.

AttributesDescription
name
string

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

TypeName
Customercustomer.segment
customer.metadata
Orderorder.amount
order.initial_amount
order.items.count
order.items.price_any
order.items.price_each
order.items.metadata_any
order.items.metadata_each
order.metadata
Campaigncampaign.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
Redemptionredemption.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
Productproduct.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
SKUsku.id
sku.price
sku.quantity
sku.discount_applicable
Publicationpublication.redeemable_by_linked_customer
Custom Eventcustom_event.metadata
Order itemsorder.items.every
order.items.any
order.items.none
order.items.cheapest
order.items.most_expensive

*Requires the property field to be defined.

property
string, null

Custom name for a metadata property associated with the condition to be satisfied. Required if the property name is any of the following:
customer_metadata
custom_event_metadata
order_items_metadata
order_metadata
product_metadata
redemption_metadata

conditionsSee: Validation Rule Conditions
rulesSee: Validation Rule Rules
error
object

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

AttributesDescription
message
string

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

Validation Rule Rules

AttributesDescription
logic
string

Defines the logic between the rules.

Example:

(1 and 2) and (3)

[propertyName]
object

Contains the name of the validation rule.

AttributesDescription
name
string

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

TypeName
Customercustomer.segment
customer.metadata
Orderorder.amount
order.initial_amount
order.items.count
order.items.price_any
order.items.price_each
order.items.metadata_any
order.items.metadata_each
order.metadata
Campaigncampaign.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
Redemptionredemption.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
Productproduct.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
SKUsku.id
sku.price
sku.quantity
sku.discount_applicable
Publicationpublication.redeemable_by_linked_customer
Custom Eventcustom_event.metadata
Order itemsorder.items.every
order.items.any
order.items.none
order.items.cheapest
order.items.most_expensive

*Requires the property field to be defined.

property
string, null

Custom name for a metadata property associated with the condition to be satisfied. Required if the property name is any of the following:
customer_metadata
custom_event_metadata
order_items_metadata
order_metadata
product_metadata
redemption_metadata

conditionsSee: Validation Rule Conditions
rules
object

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
object

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

AttributesDescription
message
string

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