# Quickstart

> Send a customer session update

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

Set up a live campaign and trigger a discount through the [Integration API](/docs/dev/integration-api/overview).

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

<StepsContainer>

## Prerequisites

Ensure you have access to the [Campaign Manager](/docs/product/get-started#sign-in-to-your-account) and [Postman](https://www.postman.com/).

## Create an Application

1. In the Campaign Manager, open <Applications className="icon"/> **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.

## Get your API key and set up Postman

1. In the Application, open <Settings className="icon"/> **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.
4. Fork the [Integration API Postman collection](https://www.postman.com/talonone-rnd/talon-one/collection/3zq30db/integration-api?sideView=variables).
5. Open the **Variables** tab and set the following values:

   | Variable      | Value                                                                                                 |
   | ------------- | ----------------------------------------------------------------------------------------------------- |
   | `APIKey_IAPI` | Your API key                                                                                          |
   | `baseUrl`     | The base URL of your Talon.One deployment.Example: `https://mycompany.europe-west1.talon.one/`. |

6. Click **Save**.

## Create and activate a campaign

Create a campaign that uses a [promotion rule](/docs/product/rules/overview#promotion-rules): when a customer applies the code `SUMMERSALE26`, they receive a 10% discount.

### Create the campaign

1. In the Campaign Manager, open <Campaigns className="icon"/> **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 <RuleBuilder className="icon"/> **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 className="icon"/> **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 className="icon"/> **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](/docs/dev/integration-api/overview).

## Send a request

Send a request to the [Update customer
session](/integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2)
endpoint to create a customer session and add a cart item and a coupon to it.

You can send this request in several ways, for example:

- **Postman**: Use the collection you [set up previously](#get-your-api-key-and-set-up-postman).
- **API reference**: Use the **Test request** button in the [Update customer
  session](/integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2)
  endpoint.
- **curl**: Use the following command, where:
  - `YOUR_BASE_URL` is the base URL of your Talon.One instance, for example, `mycompany.talon.one`.
  - `YOUR_API_KEY` is the Integration API key you [created](#get-your-api-key-and-set-up-postman).

```bash {1,6,17} title="Creating a session"
curl --request PUT 'https://YOUR_BASE_URL/v2/customer_sessions/session_12345' \
--header 'Authorization: ApiKey-v1 YOUR_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": [
 ]
}'
```

The session `session_12345` is linked to the [customer profile][customer-profiles] ID set to `John Doe` and contains one cart item and one coupon code.

Talon.One's response looks like:

```json {10,23,29} title="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`).

</StepsContainer>

## Next steps

Now you can apply the [effects][effects] from the response.

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`, apply `props.value` to the cart total. In this example, `14.0` updates the cart from $145 to $130.50.

## Related pages

- [Integration API overview][integration-api]
- [API effects][effects]
- [Integration checklist][checklist]

[integration-api]: /docs/dev/integration-api/overview.md
[effects]: /docs/dev/integration-api/api-effects.md
[checklist]: /docs/dev/get-started/integration-checklist.md
[applications]: /docs/product/applications/overview.md
[campaigns]: /docs/product/campaigns/overview.md
[customer-sessions]: /docs/dev/concepts/entities/customer-sessions.md
[customer-profiles]: /docs/dev/concepts/entities/customer-profiles.md
