Skip to main content

Quickstart 

Set up a live campaign and trigger a discount through the Integration API.

What you will learn
  • How to create a Talon.One Application and generate an API key.
  • How to build a campaign with a coupon-based discount rule.
  • How to send a customer session update via the Integration API.
  • How to read the effects from the API response.
1

Prerequisites​

Ensure you have access to the Campaign Manager and a terminal with curl installed.

If you prefer sending requests from Postman, you can set it up after creating your API key.

2

Create an Application​

  1. In the Campaign Manager, open Apps and click Create Application.

  2. Enter a name for your Application.

  3. Select a currency and timezone.

  4. In Code case sensitivity, select Case insensitive - Uppercase.

  5. In Application environment, select Sandbox and click Create Application.

    A new Application is created and opens to the Campaigns page.

3

Get your API key​

  1. In the Application, open Settings > Integration API Keys.

  2. Click Create API Key and enter a name and expiration date.

  3. Click Create API Key, then copy the key. The Campaign Manager shows the key only one time. If you lose it, create a new one.

  4. In your terminal, store the key and the base URL of your Talon.One deployment as environment variables. The base URL is the address in your browser when you use the Campaign Manager, without the path. For example, https://mycompany.europe-west1.talon.one.

    export TALON_INTEGRATION_API_KEY="YOUR_API_KEY"
    export TALON_BASE_URL="https://mycompany.europe-west1.talon.one"

    Every curl command in this guide uses these two variables, so you can copy and run them without editing.

Note

Environment variables last only for the current terminal session. If you open a new terminal, set them again.

Use Postman instead

To send requests from Postman, fork the Integration API Postman collection, open the Variables tab, and set the following values:

VariableValue
APIKey_IAPIYour API key
baseUrlThe base URL of your deployment, for example, https://mycompany.europe-west1.talon.one/.

Click Save.

4

Create and activate a campaign​

Create a campaign that uses a promotion rule: when a customer applies the code SUMMERSALE26, they receive a 10% discount.

Create the campaign​

  1. In the Campaign Manager, open Campaigns and click Create Campaign.
  2. Select From scratch, then Standard campaign.
  3. In Campaign name, enter Summer Sale.
  4. Enable the Coupons feature and click Create Campaign.

Add a rule​

  1. Open Rule Builder and click Create Rule.
  2. Enter 10% off as the rule title.
  3. Under Conditions, click Add Condition and select Coupon code is valid.
  4. Under Effects, click Add Effect, select Discount session total, and click Done.
  5. Click Save.

Create a coupon​

  1. Open Resources > Coupons and click Create Coupons.
  2. Select Universal Code and enter SUMMERSALE26 as the coupon code.
  3. Click Create Coupons.

Activate the campaign​

  1. Click Overview on the left-side menu and click Activate campaign.
  2. Click Activate to confirm.

The campaign is now live and ready to evaluate Integration API requests.

5

Send a request​

Send a request to the Update customer session endpoint to create a customer session and add a cart item and a coupon to it.

Run the following command in the terminal where you set your environment variables:

Creating a session
curl --request PUT "$TALON_BASE_URL/v2/customer_sessions/session_12345" \
--header "Authorization: ApiKey-v1 $TALON_INTEGRATION_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"customerSession": {
"profileId": "John Doe",
"cartItems": [
{
"name": "green sweater",
"sku": "SKU1234",
"quantity": 1,
"price": 140,
"category": "sweaters",
"weight": 0.5
}
],
"couponCodes": ["SUMMERSALE26"]
},
"responseContent": [
]
}'

Notice the following:

  • The session session_12345 is passed as path parameter
  • The session is linked to the customer profile ID set to John Doe
  • The session contains one cart item and one coupon code.
6

Understand the response​

Talon.One's response looks like this:

Example response
{
"createdCoupons": [],
"createdReferrals": [],
"effects": [
{
"campaignId": 2243,
"rulesetId": 8400,
"ruleIndex": 0,
"ruleName": "10% off",
"effectType": "acceptCoupon",
"triggeredByCoupon": 42542160,
"evaluationGroupID": 1,
"evaluationGroupMode": "stackable",
"props": {
"value": "SUMMERSALE26"
}
},
{
"campaignId": 2243,
"rulesetId": 8400,
"ruleIndex": 0,
"ruleName": "10% off",
"effectType": "setDiscount",
"triggeredByCoupon": 42542160,
"evaluationGroupID": 1,
"evaluationGroupMode": "stackable",
"props": {
"name": "10% off",
"value": 14.0,
"scope": "cartItems"
}
}
]
}

The important part of the response is the effects array. In this case, the rule triggered two effects:

  • acceptCoupon: the coupon code is valid.
  • setDiscount: the discount amount is in value (14.0).

Next steps​

Now you can apply the effects from the response to your platform.

For example, in an ecommerce integration, you can update your checkout and inform the shopper of their discount:

Checkout page showing updated cart total reflecting the 10% discount and applied Coupon
  • For acceptCoupon, display a confirmation. For example, a Coupon applied label next to the coupon code field.
  • For setDiscount, apply props.value to the cart total. In this example, 14.0 updates the cart from $140.00 to $126.