Create a validation rule.
🚧 Managing validation rules
It is recommended to create or update 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.
The access token received from the authorization server in the OAuth 2.0 flow.
Specify the validation rules parameters.
Request body schema for POST v1/validation-rules.
Custom, unique name for set of validation rules.
"Business Validation Rule"
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.
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.
While updating with the PUT method, you can pass "bundle_rules": null to delete the configuration; in the response, an empty object is then returned.
Contains the error message returned from API when validation / redemption fails to meet requirements of defined rules.
Type of validation rule.
expression, basic, advanced, complex Validation rule context type.
| Context Type | Definition |
|---|---|
| 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 |
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 Returns a validation rule object.
Response body schema for POST v1/validation-rules.
This is an object representing a request validation rule.
This is an object representing a response validation rule.
Custom, unique name for set of validation rules.
"Business Validation Rule"
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.
Type of validation rule.
expression, basic, advanced, complex Validation rule context type.
| Context Type | Definition |
|---|---|
| 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 |
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 Unique validation rule ID.
"val_eR1c41hu0vUU"
Timestamp representing the date and time when the validation rule was created. The value is shown in the ISO 8601 format.
"2022-03-23T07:44:00.444Z"
The type of the object represented by JSON. This object stores information about the validation rule.
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.
While updating with the PUT method, you can pass "bundle_rules": null to delete the configuration; in the response, an empty object is then returned.
Contains the error message returned from API when validation / redemption fails to meet requirements of defined rules.
Timestamp representing the date and time when the validation rule was updated. The value is shown in the ISO 8601 format.
"2022-04-26T08:35:54.960Z"
The number of instances the validation rule has been assigned to different types of redeemables.