Custom error messages

You can define a custom error message per validation rule. Error messages are going to be returned via API when code validation fails due to not meeting rule criteria.


  1. Customize standard error messages
  2. Create a validation rule error message

Custom error messages are by default visible only in the API response to the given request. Just like in the case of other objects, you are free to decide how you would like to display them to your audience. There are two types of error messages. The standard error message is displayed when a violation occurs on one of 16 application defined errors. 

On the other hand, the validation rule message is displayed when a violation occurs on a validation rule defined by you. Additionally, for validation rule violations, you can specify a fallback error message that will be displayed when there is no error message defined for a particular rule. You can define custom error messages for validation rules both via API or Dashboard. For custom standard error messages, you can provide definitions in the Dashboard and view the custom definitions, but not define them, in the API.

Create custom standard error message

You may customize a standard error message. This customization is especially useful for creating language specific error messages.  

Translate a total of 16 standard error messages, some of which are listed below, to a local language. 

  • Voucher disabled - the voucher's 'active' property is equal to 'false'
  • Voucher not active - when the current date is before the voucher's start date; the attempt to redeem occurs before the voucher's active timeframe
  • Voucher not active now - when an attempt is made to redeem the voucher outside of its specified validity window; the attempt occurs on a day other than specified in the defined timeframe
  • Voucher expired - when the voucher has expired
  • Quantity exceeded - when the voucher redemption quantity is exceeded
  • Promotion inactive - when the promotion is inactive because it has been disabled, has not started yet, has expired, and so on
  • Promotion not active now - when an attempt is made to obtain a discount outside of the promotion's specified validity window
  • Referrer not permitted to redeem - when the referral code is being redeemed by the referrer

This list is only a handful of standard error messages you can translate. You will find more errors in the application such as missing customer, missing order, gift amount exceeded and so on. Go to  Error Messages under your Project Settings to set the text for your translation.

Then click on Create new translations group.

Choose Redemption & Validation from the drop down list.

Click on Add new locale.

For each of the listed error messages, enter the customized message Text that you would like to have displayed when the error occurs.

Finally, click Save and then Save again. 

Your custom standard error messages are ready and are available in the API responses.

Please note the below API response for a standard rule violation. The redemption fails because an attempt to redeem the voucher occurs outside of its valid timeframe. The voucher not active now error message is returned with the customized message property in the error object.

Create custom validation rule error message

You may create your custom error messaging in the Validation Rules section or while creating a campaign. Note that you need to use Advanced rules builder to create custom error messages. 

If you are not yet familiar with the concept of validation rules, visit this article to get started.

Validation Rules section

When creating a validation rule, click Add error message. You can then type the message that will be returned when a customer violates this validation rule.  

Fallback error message

First, you may establish a default fallback error message applicable to all validation rule errors that have not been defined separately. 

Creating a general fallback message

Next, you can add a unique error message for each validation rule.

Custom error message

For instance, you may create a campaign only for customers who have been with your company for a year. If customers outside of the "1-year anniversary" customer segment attempted at redeeming such voucher, Voucherify would block the attempt and would return a custom error message (e.g., "You do not meet segment criteria" or " You are not a "1-year anniversary" customer").

creating error message from the Dashboard

Create custom validation rule error messages via API

You can also create custom error messages for validation rule errors programmatically. Go here to learn more details.

The content of the custom error message is going to be returned in the  error object under message property.

If you don't specify any error message for a Validation Rule, then the  error property will not be included in the API response. Here is an exemplary validation API response containing the custom error message:

Custom error message example

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us