# Use 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.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

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](/third-party-api#tag/Braze/operation/braze/createCouponReservation)
endpoint, and we'll send requests to it from Braze through the
[Connected Content](https://www.braze.com/docs/user_guide/messaging/design_and_edit/personalize/connected_content) feature.

## Talon.One requirements

- You are an [admin](/docs/product/account/account-settings/manage-roles.md#admin-role) user.
- You have set up an [Application](/docs/product/applications/create-and-manage-applications.md).
- Your Application contains a running [campaign](/docs/product/campaigns/create-and-manage-campaigns.md) with the **Coupons** feature
  [enabled](/docs/product/campaigns/settings/manage-campaign-features.md).

## Braze requirements

- You have created a [campaign](https://www.braze.com/docs/user_guide/messaging/campaigns/creating_campaign) or [canvas](https://www.braze.com/docs/user_guide/messaging/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.

## Set up the integration

<StepsContainer>

### Create an API key in Talon.One

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

1. In your Application, click <Settings className="icon" /> **Settings** > **Integration API Keys**.
1. Click <Add className="icon" /> **Create API Key**.
1. In the **Create API Key** drawer, if you are asked for a key type, select **Production**.
1. In **Key name**, type a name to identify the key.
1. In **Key expiration date**, select a date.

   :::tip
   Avoid choosing expiration dates that fall at the end of the year or during other
   high-traffic periods.
   :::

1. In **Third-party integration**, select **Yes**.
1. From **Platform**, select **{props.partner}**.
1. Click **Create API Key**.
1. Click <Copy className="icon" /> to copy the key for use.

:::note
You cannot view or copy the API key after closing the drawer.
:::

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

### Create a universal coupon code

Let's [create a universal coupon code](/docs/product/campaigns/coupons/create-coupons.md#generate-a-universal-code)
in Talon.One with the following settings:

{

  
    
      Setting
      Value
      Description
    
  
  
    
      Coupon code
      <code>WELCOME10</code>
      &ndash;
    
    
      Coupon redemption limit
      Allow unlimited redemptions
      Coupon can be redeemed an unlimited number of times.
    
    
      Per-customer redemption limit
      <code>1</code>
      Coupon can be redeemed once per customer.
    
    
      Coupon reservation limit
      Allow unlimited reservations
      Coupon can be reserved an unlimited number of times.
    
    
      Reservation mandatory
      Coupon can be redeemed only by the customers it was reserved for.
    
  

}

### Reserve 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:

```url title="POST Create coupon reservation"
https://integration.talon.one/braze/coupon_reservation
```

<Button variant="primary" size="l" href="/third-party-api#tag/Braze/operation/braze/createCoupon">
  See API docs
</Button>

To trigger the endpoint, we must use Braze's
[Connected Content](https://www.braze.com/docs/user_guide/messaging/design_and_edit/personalize/connected_content/making_an_api_call) 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.
1. 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](#create-a-universal-coupon-code), for example, `WELCOME10`.
   - `YOUR_API_KEY` is the API key you [created](#create-an-api-key-in-talonone).

   ```liquid
   {% 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}}
   ```

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

</StepsContainer>

## Check 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](/integration-api#tag/Coupons/operation/getReservedCustomers)
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](#create-a-universal-coupon-code), for example, `WELCOME10`.
   - `YOUR_API_KEY` is the API key you [created](#create-an-api-key-in-talonone).

   ```js
   curl 'https://YOUR_DEPLOYMENT_URL/v1/coupon_reservations/customerprofiles/YOUR_COUPON_CODE' --header 'Authorization: ApiKey-v1 YOUR_API_KEY'
   ```

1. Check the `integrationId` field of the response. It should contain the identifier you provided
   in the [Braze call](#reserve-the-coupon-code).
