Skip to main content

Using universal coupons and reservations with Braze

In this tutorial, we set up Braze to use universal coupons with reservations. This allows us to use the same coupon code for a particular group of customers.

Let's imagine you want to email a WELCOME10 coupon to customers, but only new customers should be able to redeem it. The coupon should give them 10% off their first purchase.

To do so, we'll rely on the Braze-specific Create coupon reservation endpoint, and we'll send requests to it from Braze through the Connected Content feature.

Talon.One requirements

  • You are an Admin user.
  • You have set up an Application.
  • Your Application contains a running campaign with the Coupons feature enabled.

Braze requirements

  • You have created a campaign or canvas in Braze.
  • You have a way to identify a given customer across Talon.One and Braze. In this tutorial, we assume a customer's Talon.One integrationId is always equal to Braze's user_id. You can also create a new property on your Braze customer profiles to store Talon.One's integration ID.

Creating an API key in Talon.One

In the Campaign Manager, create a Braze-specific API key:

  1. In your Application, click Settings > Integration API Keys.

  2. Click Create API Key.

  3. In the Create API Key drawer, select Production as the key type.

  4. In Key name, type a name to identify the key.

  5. In Key expiration date, select a date.

  6. In Third-party integration, select Yes.

  7. From Platform, select Braze.

  8. Click Create API Key.

  9. Click to copy the key for use.

    note

    You cannot view or copy the API key after closing the drawer. If you lose it, create another API key.

We will use the API key in the Braze campaign template.

Creating a universal coupon code

Let's create a universal coupon code in Talon.One with the following settings:

SettingValueDescription
Coupon codeWELCOME10
Coupon redemption limitAllow unlimited redemptionsCoupon can be redeemed an unlimited number of times.
Per-customer redemption limit1Coupon can be redeemed once per customer.
Coupon reservation limitAllow unlimited reservationsCoupon can be reserved an unlimited number of times.
Reservation mandatoryCoupon can be redeemed only by the customers it was reserved for.

Reserving the coupon code

Let's reserve the coupon we created for a customer. This makes the coupon redeemable by that customer.

To do so, we call the following endpoint:

POST Create coupon reservation
https://integration.talon.one/braze/coupon_reservation

See API Docs

To trigger the endpoint, we must use Braze's Connected Content feature.

important

We assume that your customer profile in Braze contains a unique identifier that is equal to the customer integration ID in Talon.One. In this tutorial, we use ${user_id}. Ensure the user ID matches the integration ID in Talon.One.

  1. Open your Braze campaign or canvas for editing.

  2. Add the following Connected Content call to the body of your message, where:

    • YOUR_DEPLOYMENT_URL is the base URL of your Talon.One deployment, for example, mycompany.europe-west1.talon.one.
    • YOUR_COUPON_CODE is the universal coupon code you created, for example, WELCOME10.
    • YOUR_API_KEY is the API key you created.
    {% capture postbody %}
    {"deploymentUrl": "YOUR_DEPLOYMENT_URL", "couponValue": "YOUR_COUPON_CODE", "integrationId":"{{${user_id}}}"}
    {% endcapture %}

    {% connected_content https://integration.talon.one/braze/coupon_reservation
    :headers {
    "Authorization": "ApiKey-v1 YOUR_API_KEY"
    }
    :method post
    :body {{postbody}}
    :content_type application/json
    :save result
    :retry
    %}

    Your coupon code is: {{result.value}}
  3. To test your request:

    1. In the sidebar, click Preview & Test.
    2. In Preview message as user, select Search User and search for an existing user in Braze.
      You should see the coupon code.

Checking the reservation

Let's check whether our coupon code has been successfully reserved.

To do so, we use the List customers that have this coupon reserved endpoint of the Integration API:

  1. Use curl or a similar tool to send the following request, where:

    • YOUR_DEPLOYMENT_URL is the base URL of your Talon.One deployment, for example, mycompany.europe-west1.talon.one.
    • YOUR_COUPON_CODE is the universal coupon code you created, for example, WELCOME10.
    • YOUR_API_KEY is the API key you created.
    curl 'https://YOUR_DEPLOYMENT_URL/v1/coupon_reservations/customerprofiles/YOUR_COUPON_CODE' --header 'Authorization: ApiKey-v1 YOUR_API_KEY'
  2. Check the integrationId field of the response. It should contain the identifier you provided in the Braze call.