Quickstart
Set up a live campaign and trigger a discount through the Integration API.
- 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.
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.
Create an Application
-
In the Campaign Manager, open Apps and click Create Application.
-
Enter a name for your Application.
-
Select a currency and timezone.
-
In Code case sensitivity, select Case insensitive - Uppercase.
-
In Application environment, select Sandbox and click Create Application.
A new Application is created and opens to the Campaigns page.
Get your API key
-
In the Application, open Settings > Integration API Keys.
-
Click Create API Key and enter a name and expiration date.
-
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.
-
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
curlcommand in this guide uses these two variables, so you can copy and run them without editing.
Environment variables last only for the current terminal session. If you open a new terminal, set them again.
To send requests from Postman, fork the Integration API Postman collection, open the Variables tab, and set the following values:
| Variable | Value |
|---|---|
APIKey_IAPI | Your API key |
baseUrl | The base URL of your deployment, for example, https://mycompany.europe-west1.talon.one/. |
Click Save.
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
- In the Campaign Manager, open Campaigns and click Create Campaign.
- Select From scratch, then Standard campaign.
- In Campaign name, enter
Summer Sale. - Enable the Coupons feature and click Create Campaign.
Add a rule
- Open Rule Builder and click Create Rule.
- Enter
10% offas the rule title. - Under Conditions, click Add Condition and select Coupon code is valid.
- Under Effects, click Add Effect, select Discount session total, and click Done.
- Click Save.
Create a coupon
- Open Resources > Coupons and click Create Coupons.
- Select Universal Code and enter
SUMMERSALE26as the coupon code. - Click Create Coupons.
Activate the campaign
- Click Overview on the left-side menu and click Activate campaign.
- Click Activate to confirm.
The campaign is now live and ready to evaluate Integration API requests.
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.
- curl
- Postman
- API reference
Run the following command in the terminal where you set your environment variables:
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": [
]
}'
-
Open the collection you forked and select the Update customer session request.
-
Set the path parameter
:customerSessionIdtosession_12345. -
Replace the request body with the following:
Creating a session{"customerSession": {"profileId": "John Doe","cartItems": [{"name": "green sweater","sku": "SKU1234","quantity": 1,"price": 140,"category": "sweaters","weight": 0.5}],"couponCodes": ["SUMMERSALE26"]},"responseContent": []} -
Click Send.
-
Open the Update customer session endpoint and click Try it.
-
Enter your API key and base URL.
-
Set
customerSessionIdtosession_12345. -
Replace the request body with the following:
Creating a session{"customerSession": {"profileId": "John Doe","cartItems": [{"name": "green sweater","sku": "SKU1234","quantity": 1,"price": 140,"category": "sweaters","weight": 0.5}],"couponCodes": ["SUMMERSALE26"]},"responseContent": []} -
Click Send.
Notice the following:
- The session
session_12345is 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.
Understand the response
Talon.One's response looks like this:
{
"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 invalue(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:
- For
acceptCoupon, display a confirmation. For example, a Coupon applied label next to the coupon code field. - For
setDiscount, applyprops.valueto the cart total. In this example,14.0updates the cart from $140.00 to $126.