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. Create a custom error message via the Dashboard.
  2. Create a custom error message via API.

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.

Additionally, you can specify a fallback error message that will be displayed when there is no error message defined for the particular rule. 
You can define custom error messages both via API or Dashboard.

Create custom errors via Dashboard

You may create your custom error messaging in the Validation Rules section or while creating a campaign.

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

Validation Rules section

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 errors messages via API

You can also create custom error messages 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