Skip to main content
Head over to our Github Repository to see examples of connected content scripts.
Keep in mind that all examples below use Voucherify publication source id, and Braze cache and retry parameters to limit API calls invoked by a Braze campaign. You must be aware of the following consequences:
  • It isn’t possible to publish and send different codes to the same customer in a single Braze campaign.
  • If your Voucherify campaign uses the join only once feature, you need to remove source_id from the connected content body as described in Secure your Connected Content scripts.

API endpoints

Shared ClusterEndpoint for Braze Connected Content
Europe (default)https://api.voucherify.io/v1/publications
United Stateshttps://us1.api.voucherify.io/v1/publications
Asia (Singapore)https://as1.api.voucherify.io/v1/publications

Publish and send unique coupon code

In this example, the Connected Content script calls Voucherify API to publish a unique coupon code and send it in the Braze message. Each Braze user receives only one unique code.
{% assign braze_campaign_id = {{campaign.${api_id}}} %}
{% assign customer_id = {{${user_id}}} %}
{% assign source_id = braze_campaign_id | append: customer_id %}
{% assign voucherify_campaign_id = "CAMPAIGN_ID" %}
{% assign cache_id = source_id %}

{% connected_content 
   YOUR API ENDPOINT/v1/publications?cache_id={{cache_id}}
   :method post
   :headers {
        "X-App-Id": "VOUCHERIFY-APP-ID",
        "X-App-Token": "VOUCHERIFY-APP-TOKEN"
   }
   :body campaign={{voucherify_campaign_id}}&customer={{customer_id}}&channel=Braze&source_id={{source_id}}
   :content_type application/json
   :cache_max_age
   :retry
   :save publication
 %}

Invite new referrers

This Connected Content script enables you to publish and send unique referral codes to selected Braze users. Each user receives only one referral code to share with other users and gain new referrals.
{% assign braze_campaign_id = {{campaign.${api_id}}} %}
{% assign customer_id = {{${user_id}}} %}
{% assign source_id = braze_campaign_id | append: customer_id %}
{% assign voucherify_campaign_id = "CAMPAIGN_ID" %}
{% assign cache_id = source_id %}

{% connected_content 
   YOUR API ENDPOINT/v1/publications?cache_id={{cache_id}}
   :method post
   :headers {
  	"X-App-Id": "VOUCHERIFY-APP-ID",
        "X-App-Token": "VOUCHERIFY-APP-TOKEN"
   }
   :body campaign={{voucherify_campaign_id}}&customer={{customer_id}}&channel=Braze&source_id={{source_id}}
   :content_type application/json
   :cache_max_age
   :retry
   :save publication
 %}

Fetch loyalty card balance

Here is an example of a Connected Content script that pulls the current loyalty balance based on the loyalty card code that was sent beforehand to Braze as a custom attribute. Note that you need to store the loyalty card code as a custom attribute in Braze user’s profile before using this script.
{% assign braze_campaign_id = {{campaign.${api_id}}} %}
{% assign customer_id = {{${user_id}}} %}
{% assign source_id = braze_campaign_id | append: customer_id %}
{% assign voucherify_campaign_id = "CAMPAIGN_ID" %}
{% assign cache_id = source_id %}

{% connected_content 
   YOUR API ENDPOINT/v1/loyalties/{{voucherify_campaign_id}}/members/{{custom_attribute.${loyalty.card}}}?cache_id={{cache_id}}
   :method get
   :headers {
	"X-App-Id": "VOUCHERIFY-APP-ID", 
        "X-App-Token": "VOUCHERIFY-APP-TOKEN"
   }
   :content_type application/json
   :cache_max_age
   :retry
   :save member
 %}

Source ID configurations

ConfigurationEffect
{{campaign.${dispatch_id}}}Ensures that all customers within a single send-out will use the same publication.
{{campaign.${api_id}}}Ensures that all customers within a single campaign will use the same publication.
{{${user_id}}} or {{${braze_id}}}Ensures that every customer will use the same publication no matter which campaign is sent (you can use ${user_id} which is an external_id and ${braze_id} which is an internal id).
{{campaign.${dispatch_id}}} and {{campaign.${user_id}}}Each customer within a single send-out will use the same unique publication.

Display snippets

Published code

{{publication.voucher.code}}

Loyalty card balance

{{member.loyalty_card.balance}}
Last modified on March 13, 2026