Prerequisite: Recommended readingIt’s recommended to read the following articles before exploring the scripts:
https://api.voucherify.io. If your project is in a different region, change the endpoint accordingly.
Publish and send unique code
This script calls the Voucherify API to publish a unique code and send it in a Braze message. Each Braze user receives only one unique code. Use this snippet to distribute codes in the following scenarios:- Abandoned cart recovery
- Braze user performs a custom event – reward for an achievement
- Invite referrers to a referral program
- Sending the same through multiple channels (for example, email and push)
Publish and send unique code
Display different voucher details: Snippets
Display different voucher details: Snippets
To display the published code in your message, use the following snippet:If you publish a gift card, you can additionally display its value:If you publish a loyalty card when a customer fulfils an earning rule and receives a card with a loyalty card balance, use the following snippet:If the points have an expiration date, use:
Published code snippet
Display gift card balance
Display loyalty card balance
Display loyalty card point expiration date
Generate and publish a discount coupon
This script generates a coupon with a custom prefix based on a customer attribute (for example, phone number or email) and then publishes it. The two-step process first creates the voucher, then assigns it to the customer. Use this snippet to distribute personalized codes in the following scenarios:- VIP welcome offers with recognizable, branded codes
- Phone-number-based coupons for SMS campaigns where the code doubles as an identifier
- Personalized codes for partner or co-branded promotions
- Event-specific codes tied to customer attributes for easy tracking
Generate and publish a discount coupon
Display generated coupon details: Snippets
Display generated coupon details: Snippets
To display the generated and published code in your message, use the following snippet:If you publish a gift card, you can additionally display its value:
Published code snippet
Display gift card balance
List unused coupons
This script retrieves all unredeemed discount coupons assigned to a Braze user (lines 15-19). It loops through the customer’s vouchers and displays only the ones that haven’t been used. Use this snippet to remind customers about available codes in the following scenarios:- Weekly or monthly “wallet” digest emails listing available coupons
- Re-engagement campaigns reminding inactive users they have unused discounts
- Post-purchase follow-ups nudging customers to use remaining codes
- End-of-campaign reminders before codes expire
List unused coupons
Display unused coupon details: Snippets
Display unused coupon details: Snippets
Use this snippet to show additional details like the discount value for each voucher:Use this snippet to display the expiration date for urgency:
Display coupon with discount
Display coupon expiration date
List all codes and publish a new one if there are none
This script checks if a customer already has an available code from a specific campaign. If the customer has no codes, or if their most recent code was already redeemed, it publishes a new one. This ensures every message contains a valid, usable code. Use this snippet to guarantee a valid code in the following scenarios:- Always-on promotional campaigns where customers should always have an active code
- Recurring campaigns where a new code is needed after each redemption
- Win-back flows that check for an existing offer before generating a new one
- Multi-touch nurture sequences where you want one active code per customer at all times
List codes and publish if none
Display the code: Snippets
Display the code: Snippets
Place this snippet where you want to display the discount coupon in your message:For gift cards, you can display also their balance:
Display discount coupon
Display gift card balance
Resend codes
Prerequisite: Store incentive codes as custom attributesFor this script to work, you need to first assign a discount coupon, gift card, or referral code to a Braze user and save the code and expiration date as custom attributes.Read Distribute to Braze custom attributes to learn how to send Voucherify data as Braze custom attributes.
- Expiration reminder emails sent a few days before a code expires
- Re-engagement campaigns for customers who received but never used a code
- Multi-channel reminders (for example, push notification after an email)
- Post-purchase follow-ups reminding customers about their remaining gift card or referral code
Resend codes
Display resent code details: Snippets
Display resent code details: Snippets
To display the incentive code:To show the expiration date to create urgency:To display different messages based on redemption status:
Incentive code snippet
Display expiration date
Conditional redemption status
Fetch loyalty card balance
Prerequisite: Send loyalty card code as a custom attributeFor this script to work, you need to store the loyalty card code as a custom attribute in Braze user’s profile.Read Distribute to Braze custom attributes to learn how to send Voucherify data as Braze custom attributes.
- Point balance reminder email
- Post-purchase point update
- Tier-based messaging
- Monthly loyalty statement
- Re-engagement for inactive members
Fetch loyalty card balance
Display loyalty card details: Snippets
Display loyalty card details: Snippets
Use the following snippets to display loyalty card details.Display the loyalty card code:Display the current balance:If points are about to expire, create a sense of urgency to spend them. Display the number of expiring points and the date when they will expire:If you use pending points, display the number of points that are in the pending state:If you send emails to remind users about their point balance, you can use the following template:Use the following template to message users about their progress in achieving loyalty tiers:
Loyalty card code snippet
Loyalty card balance snippet
Display loyalty card expiring points with date
Display loyalty card point pending points
Remind users about their balance
Tier-based messaging with conditional logic
Add loyalty points with a custom event earning rule
This script sends a custom event (lines 5-12) to Voucherify when a Braze message is delivered. The event triggers an earning rule in your loyalty campaign, which awards points to the customer. Different segments can receive different point amounts based on the earning rule configuration. Use this snippet to award loyalty points in the following scenarios:- Reward customers for opening or engaging with a campaign message
- Award bonus points during double-points promotional periods
- Grant points for completing a profile, survey, or onboarding step
- Trigger milestone rewards when a customer reaches a segment threshold
Add loyalty points with a custom event
How it works: Custom event earning rules
How it works: Custom event earning rules
The script sends a custom event to Voucherify with the customer’s
source_id. Voucherify evaluates the event against your earning rules and awards points accordingly.To set this up:- Create a custom event schema in Voucherify under Project settings > Custom events.
- Create an earning rule in your loyalty campaign that listens for this event.
- Replace
"Event Name"in the script with your custom event name.
Add credits to a gift card
Prerequisite: Send the gift card code as a custom attributeFor this script to work, you need to store the gift card code as a custom attribute in Braze user’s profile.Read Distribute to Braze custom attributes to learn how to send Voucherify data as Braze custom attributes.
- Birthday or anniversary bonus credits
- Compensation credits for a negative customer experience
- Seasonal top-ups during holiday campaigns
- Reward credits for completing a purchase or hitting a spending milestone
"amount": 1000 is a value in the smallest currency units (for example, cents for USD or EUR).
Add credits to a gift card
Display gift card balance update: Snippets
Display gift card balance update: Snippets
After adding credits, you can confirm the top-up in the message. The
:no_cache attribute ensures the balance reflects the latest update.To notify the customer about the added credits:Display added amount
Tips for fetching data with Braze Connected Content
Use the following tips to format data fetched from Voucherify.Format date and time
Format date and time
If you fetch date and time, for example
expiration_date for points or codes, you can format it according to your preferences as follows:- day, month, year:
{{voucher.expiration_date | date: "%d.%m.%Y"}} - day, month, year and time:
{{voucher.expiration_date | date: "%d.%m.%Y o %H:%M"}} - month, day, year:
{{voucher.expiration_date | date: "%B %d, %Y"}} - date and time adjusted to the time zone:
{{ voucher.expiration_date | time_zone: 'Europe/Warsaw' | date: "%d.%m.%Y %H:%M" }}
Adjust decimals
Adjust decimals
If you fetch a gift card balance or discount amount, Voucherify returns the value multiplied by 100. Divide by
100.0 to display the correct currency amount.For example {{ voucher.gift.balance | divided_by: 100.0 }} renders "balance": 10000 as 100.0If your country uses a comma (,) as a decimal separator, append replace: '.', ',' to the snippet:Display added amount

