Skip to main content
Without the following settings, each time a connected content message is triggered, it calls the Voucherify API at least two times. The following settings reduce the number of API calls invoiced by Braze and cut the risk of hitting the hard-blocking API limit that may break the message delivery.

Rate limiter

When configuring campaigns in Braze, limit the number of messages sent by Braze per minute. This secures both Braze and Voucherify APIs against hitting too much traffic from your campaign. When targeting users during campaign setup, choose to limit the sending rate to 500 messages per minute.

Add caching to POST calls

All examples of Connected Content in this tutorial include default caching to reduce the number of API calls triggered by Braze. Note that removing cache from your script will double the number of Voucherify API calls used by Connected Content.
Connected Content calls made via HTTP POST don’t cache by default and will make two API requests per each published code. This behavior can drain your hourly and monthly limits. The caching mechanism will allow you to limit that to one API call per voucher publication. To add caching to POST calls, you must perform two steps:
  • Add a :cache_max_age attribute. By default, the caching duration is 5 minutes. You can customize the duration using seconds. It can be set between 5 minutes to 4 hours. Example: :cache_max_age 3600 will cache for 1 hour.
  • Provide a caching key cache_id={{cache_id}} in the destination endpoint query parameter so Braze can identify a unique publication. First, define the variable and then append the unique query string to your endpoint. This will differentiate each publication by the source_id.
<body class="body" style="padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#f4f4f7; -webkit-text-size-adjust:none">
{% 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 = "camp_Z..." %}
{% assign cache_id = source_id %} //Caching key

{% connected_content
   https://api.voucherify.io/v1/publications?cache_id={{cache_id}} //Caching key
   :method post
   :headers {
     "X-App-Id": "490a3fb6-a...",
     "X-App-Token": "328099d5-a..."
   }
   :body campaign={{voucherify_campaign_id}}&customer={{customer_id}}&channel=Braze&source_id={{source_id}}
   :content_type application/json
   :cache_max_age //Fill in the max_age
   :save publication
%}
Braze caches the API calls based on the URL. The unique string used as a query parameter is ignored by Voucherify, but it distinguishes different API requests for Braze and allows to cache each unique attempt separately. Without that query parameter, every customer will receive the same coupon code for the cache duration.

Retry attribute

Connected Content does not validate the Voucherify response, so we additionally recommend adding a retry attribute in the Connected Content script. The connected content logic will try to retry 5 times before aborting the message (it will respect the rate limiter). This method will help prevent cases of failed code publishing when it takes a little longer to fetch data from Voucherify. If you do not use :retry, then irrespective of the response returned from Voucherify, Braze will attempt to send the distribution, which may result in generating emails without a published code.
<body class="body" style="padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#f4f4f7; -webkit-text-size-adjust:none">
{% 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 = "camp_Z..." %}
{% assign cache_id = source_id %}

{% connected_content
   https://api.voucherify.io/v1/publications?cache_id={{cache_id}}
   :method post
   :headers {
     "X-App-Id": "490a3fb6-a...",
     "X-App-Token": "328099d5-a..."
   }
   :body campaign={{voucherify_campaign_id}}&customer={{customer_id}}&channel=Braze&source_id={{source_id}}
   :content_type application/json
   :cache_max_age
   :retry //Retry attribute
   :save publication
%}

Unique publication per customer

The source_id parameter in the script body provides that each customer can receive only one unique code in a single Braze campaign. As a result, even if Braze unintentionally multiplies the request, each user will receive the same unique code that was published to him/her in the first message.
<body class="body" style="padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#f4f4f7; -webkit-text-size-adjust:none">
{% assign braze_campaign_id = {{campaign.${api_id}}} %}
{% assign customer_id = {{${user_id}}} %}
{% assign source_id = braze_campaign_id | append: customer_id %} //Here
{% assign voucherify_campaign_id = "camp_Z..." %}
{% assign cache_id = source_id %}

{% connected_content
   https://api.voucherify.io/v1/publications?cache_id={{cache_id}}
   :method post
   :headers {
     "X-App-Id": "490a3fb6-a...",
     "X-App-Token": "328099d5-a..."
   }
   :body campaign={{voucherify_campaign_id}}&customer={{customer_id}}&channel=Braze&source_id={{source_id}} //Here
   :content_type application/json
   :cache_max_age
   :retry //Retry attribute
   :save publication
%}
You can modify {{source_id}} and its effect on publications by using the following 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.

Customer can join only once

If your Voucherify campaign has a limit Customers can join only once, remove publication source id from the script body. Voucherify will make sure that each Braze message to the same customer will deliver the same code that was published in the first place. Your Connected Content script should be as follows:
{% assign braze_campaign_id = {{campaign.${api_id}}} %}
{% assign customer_id = {{${user_id}}} %}
{% assign cache_id = braze_campaign_id | append: customer_id %}
{% assign voucherify_campaign_id = "CAMPAIGN_ID" %}

{% connected_content 
   https://api.voucherify.io/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
   :content_type application/json
   :cache_max_age
   :retry
   :save publication
 %}
Last modified on March 13, 2026