The examples below use the default API address
https://api.voucherify.io.If your API endpoint is in a different region, remember to change it.Rate limiter
When configuring campaigns in Braze, limit the number of messages sent by Braze per minute. This protects both Braze and Voucherify APIs from excessive traffic. Set the sending rate based on your Voucherify API rate limits and account for other API call needs.Add caching to calls
Caching reduces the number of API calls triggered by Braze. Connected Content calls don’t cache by default and make two API requests per call. This can quickly drain your hourly and monthly limits. Caching reduces this to one API call per request. Add caching to calls as follows:- Provide a caching key
cache_id={{cache_id}}in the destination endpoint query parameter so Braze can identify a unique call. First, define the variable, then append the unique query string to your endpoint. In the example, this differentiates each publication by thesource_id. - Add a
:cache_max_ageattribute. You can customize the duration using seconds. It can be set between 5 minutes to 4 hours. Example::cache_max_age 3600will cache for 1 hour.
By default, the caching duration is 5 minutes.
Caching in publications
Braze caches API calls based on the URL. The unique string used as a query parameter is ignored by Voucherify, but it lets Braze distinguish different API requests and cache each one separately.Without this query parameter, every customer receives the same value (for publications, the same coupon code) for the cache duration.
Retry attribute
Add a retry attribute to your Connected Content script. Connected Content doesn’t validate the Voucherify response, so without retry, a slow or failed request results in a message sent without data. With:retry, Braze retries up to 5 times before aborting the message.
Retry in publications
Unique publication per customer
Thesource_id parameter in the script body ensures each customer receives only one unique code per Braze campaign. Even if Braze sends duplicate requests, the customer gets the same code that was published in the first message.
Source ID in publications
Publication with customer can join only once
If your Voucherify campaign is set to Customers can join campaign only once, removesource_id from the script body.
Voucherify ensures that each Braze message to the same customer delivers the same code that was published in the first message.
Your Connected Content script should be as follows:
Customer can join only once publication script
Source ID configurations
You can modify{{source_id}} and its effect on publications with the following configurations.
| Configuration | Effect |
|---|---|
{{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 uses the same publication regardless of which campaign is sent. ${user_id} is the external ID and ${braze_id} is the internal Braze ID. |
{{campaign.${dispatch_id}}} and {{campaign.${user_id}}} | Each customer within a single send-out will use the same unique publication. |
Converting Connected Content scripts to Canvas
The examples above are prepared for Braze campaigns. However, you can use them in Braze Canvas as well. To use the script in Canvas, delete the line with{% assign braze_campaign_id = {{campaign.${api_id}}} %} and add {% assign braze_id = canvas.${id} %}.

