> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Voucherify

# Introduction

[Voucherify](https://www.voucherify.io/) is an all-in-one promotional platform that allows for personalized campaigns and loyalty programs that drive user engagement and retention.

# MoEngage × Voucherify

The MoEngage and Voucherify integration allows you to grow your promotional campaigns by sending unique codes through the use of Content APIs. With this integration, you can inform your customers of promotions and distribute personalized coupons to every one of them. Thanks to event-triggered MoEngage campaigns, you can react to certain occasions with new Voucherify coupons and gift cards being delivered to your customers.

The below example implements the following scenario:

1. Customers who haven’t visited the store should be offered a discount coupon to draw them back.
2. Only the customer who has been gifted with the voucher should be able to redeem it.
3. The customer should receive personalized coupons via email.

# Integration

<Info>
  **Prerequisites**

  * Ensure you have access to your Voucherify account.
</Info>

## Step 1: Prepare a Voucherify campaign to engage inactive customers

1. On your Voucherify dashboard, create a new [Unique Coupons Campaign](https://support.voucherify.io/article/46-bulk-unique-codes-campaign).
2. Get your Campaign ID by calling [the get campaign endpoint](https://docs.voucherify.io/reference/get-campaign) or in your browser address bar when you open the campaign dashboard:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879185978388.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=b9a9babb722578414251c226dea0d65a" alt="" width="796" height="29" data-path="images/partner_15879185978388.png" />

## Step 2: Configure a MoEngage ContentAPI endpoint which will publish new code from the above campaign

On your MoEngage account, navigate to Settings → App → APIs → Content API tab and click the ‘Add’ button.

1. API Name: this is the name of the Content API endpoints. It cannot be changed afterward. In this case, it is named `new_reactivation_voucher` because it will send out voucher codes from the `Customer Reactivation` campaign.
2. API Url: type in the address of the Create Publications endpoint: `{{API_URL}}/v1/publications/create`. You can find your API Url in your Voucherify Project Settings in the `Application Information` section.
3. In the *Parameters* tab:
   1. Add a *campaign* parameter and fill in your Voucherify campaign ID.
   2. Add a *customer* parameter and fill in the MoEngage field that should be used as the customer’s source\_id field in Voucherify. In this case, the customer’s email is used as source\_id. You can learn more about MoEngage users’ attributes [here](/user-guide/data/event-data/derived-events-and-attributes).

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879310627732.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=ba3b205f73891980dbeecab3044d2b62" className="mr-auto" width="605" height="463" data-path="images/partner_15879310627732.png" />

4. In the *Headers* tab:
   1. Add `X-App-Id` and `X-App-Token` headers. You can generate the application keys for integration with MoEngage in your Voucherify Project Settings, in the `Integration Keys` section.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879301166612.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=e386473a7545cf3e9ad70b7ff9babf2c" className="mr-auto" width="777" height="464" data-path="images/partner_15879301166612.png" />

2. Set `Content-Type` header to `application/json`.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879333346580.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=8846d9178b6488ae9fce7709fb178797" className="mr-auto" width="606" height="539" data-path="images/partner_15879333346580.png" />

5. After you save the configuration, you can test it with a *play* icon. If everything was configured correctly, you will see Voucherify’s response.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879370756884.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=e08ee141c589d007e10f8c0db1eff53f" className="mr-auto" width="681" height="368" data-path="images/partner_15879370756884.png" />

## Step 3: Use the Content API endpoint in a MoEngage campaign

1. Create a new MoEngage campaign.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879396555924.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=5f3a44c3c4697e4f1291f683ca340d44" className="mr-auto" width="649" height="610" data-path="images/partner_15879396555924.png" />

2. Prepare the email content. Using the templating language Jinja you can insert e.g. customer name into the content and call the Content API endpoint created in step 2, parse its response, and display the desired information to the customer. You can find out more about using Jinja in MoEngage [in this article](/user-guide/campaigns-and-channels/getting-started/message-personalization/jinja-templating-language).
   1. To call Voucherify’s create publication endpoint and publish a new code to an email’s recipient use this code snippet:

```jinja wrap theme={null}
   {% set publication
        = ContentApi.new_reactivation_voucher({({"params":{"customer":"{{UserAttribute['Email
        (Standard)']}}"}})}) %}
```

2. To extract only the published voucher’s code from the response, use this expression `{{publication.voucher.code}}`

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879477980180.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=90e4666b0ec851204b01713666bf1d25" className="mr-auto" width="827" height="362" data-path="images/partner_15879477980180.png" />

3. You can preview how the message will look to a particular customer after you click the preview button in the template editor, [in the personalised mode](/user-guide/campaigns-and-channels/getting-started/message-personalization/personalized-preview) or you can test it by sending an email using the *Test Campaign* field below the template editor.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879480332180.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=750559b82340e953a1e2f14f7cb7c3b7" className="mr-auto" width="704" height="613" data-path="images/partner_15879480332180.png" />

4. When you publish your campaign and messages will be sent (on a scheduled time or as soon as possible), each message will be tailored for every customer and will contain a voucher code that has been published to them:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879482764436.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=0d3ec3219e5ba51e94d406bbb4a327db" className="mr-auto" width="1022" height="844" data-path="images/partner_15879482764436.png" />

5. You can also observe each publication call made during the email send-out in the Audit Log in your Voucherify Dashboard:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879531262868.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=95a9e4fa19e7e3b087f14df95e5210c9" className="mr-auto" width="1021" height="723" data-path="images/partner_15879531262868.png" />

And see generated codes on your Voucherify campaign dashboard:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879535034516.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=8db0f8df13e1b094678e9db02ca046c3" className="mr-auto" width="1136" height="1011" data-path="images/partner_15879535034516.png" />

## Referral code and loyalty card publication

The process of assigning a referral code or loyalty card is very similar to the one described above. All you need to do is to change the campaign name parameter to the referral or loyalty campaign that you have created. Here you can learn more about Voucherify [referral programs](https://support.voucherify.io/article/48-referral-program-basics) and [loyalty programs](https://support.voucherify.io/category/389-loyalty-campaigns).

In this example, we’ll retrieve the customer’s code from the referral program with the id: `camp_f0bKCWIYyTfOept56g2UMLY7`. Thanks to the ‘Customer will be allowed to join campaign only once’ option turned on in the referral program configuration if the customer is already a program member, then their card code will be returned and if they have not yet got a referral code assigned, they will and new code will be present in the response.

1. Configure the Content API endpoint:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15879519884692.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=23e0d000ad49ec8e7a285ab42be4fa16" className="mr-auto" width="605" height="463" data-path="images/partner_15879519884692.png" />

2. To invoke the function to retrieve the loyalty card use the following code:

```django wrap theme={null}
{% set ref_code = ContentApi.get_customer_referral_code({({"params":{"customer":"{{UserAttribute['Email
    (Standard)']}}"}})}) %}
```

The customer’s referral or loyalty card code will be accessible using the same snippet: `{{ref_code.voucher.code}}`. The customer can share their referral code with a friend. When they use it during making a purchase, the referrer will be awarded the gift you’ve set up in the Voucherify Dashboard.
