How to add custom attributes (metadata) to Voucherify objects?

In this section:

  1. Create a metadata - schema validation
  2. Create a campaign with schema validation
  3. Invoke redemption
  4. Target specific segments

Schema validator allows you to take care of the integrity of your metadata. This is achieved by enabling administrators to set a type of each metadata field and to define if it’s optional or not. The schema works for every object type:

  • campaigns
  • vouchers
  • customers
  • SKUs
  • products
  • redemptions

Only Administrator can access and modify the validation scheme.

Create a metadata - schema validation

Let's see an example of the schema validator. We're going to add a custom field `affiliate_ID` to all campaign and redemption objects in the project.


To start with, go to the project settings and find Metadata - Schema Validation section. 


Choose to edit the schema


First, choose Voucherify objects to assign metadata. You can define properties for campaigns, vouchers, customers, SKUs, products or redemptions


In the next step, define a property name and type. Let's use an affiliate_ID as a property assigned to the project's campaigns and redemptions.

While choosing property type, you can choose from text, number, flag (true/false), date and date time. 


Additionally, you can mark the checkbox to set each property as optional. Otherwise, it'll be treated as required. 

In the last step, you can add some optional length constraints or even set a condition that the metadata property has to be an exact match to the value (or many custom values)

One metadata property can be defined by many restrictions, and each restriction can be defined by many different values:


When all campaigns' restrictions are in place, confirm with ADD DEFINITION and SAVE your schema.


Now, let's define all redemptions invoked amongst this project by the same affiliate_ID

Run a campaign 

As a result, while creating a new campaign (by a user assigned to this project) in 5th step of a campaign creator, there will be a default metadata field with an affiliate_ID. To create a campaign, the user has to put the required property value, set by a project administrator in the validation schema.

Otherwise, the user won't be able to save and generate campaign.

Invoke redemption

Additionally, by adding the same restriction to a redemption invoked in the context of this project, a field with the particular affiliate_ID is required for a redemption request to be valid.

Note: In case you add properties (definitions/restrictions) to a campaign and a voucher object at once, in voucher's view you'll see a validation schema from a campaign and a voucher section.

Target specific segments

You can create metadata validation schema for "customer" objects and use it for a later segmentation. By way of example, you can add a date field to the schema and collect information about specific dates, e.g. date of signing up. 

After adding this field, you'll be able to filter out your clients by using a particular date Later on, you can easily create a segment with customers who meet criteria defined by schema properties

Watch this short video to see the workflow step by step:

You can also follow this  guide to learn more about customer segments.