# Update upsell campaign

Use the **updateUpSellCampaign** method to update an upsell campaign via JSON-RPC API 6.0.

## Request parameters

<table><thead><tr><th width="400.7332763671875">Parameter Name</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>sessionId</code></td><td><strong>Required (string)</strong><br>Unique 2Checkout session ID code.</td></tr><tr><td><code>Code</code></td><td><strong>Required (string)</strong><br>The code of the upsell campaign in UUID format.</td></tr><tr><td><code>UpsellCampaign</code></td><td><strong>Required (object)</strong><br>New upsell campaign definition.</td></tr><tr><td><code>Name</code></td><td><strong>Required (string)</strong><br>Name of campaign, max 500 characters.</td></tr><tr><td><code>StartDate</code></td><td><strong>Optional (string)</strong><br>The date when the up-sell campaign starts, in the YYYY-MM-DD format. Can be NULL (starts immediately after enabling).</td></tr><tr><td><code>EndDate</code></td><td><strong>Optional (string)</strong><br>The date when the up-sell campaign ends, in the YYYY-MM-DD format. Can be NULL (ends immediately after disabling).</td></tr><tr><td><code>DisplayForManualRenewals</code></td><td><strong>Required (boolean/integer)</strong><br>Flag to control if the campaign will be displayed for manual subscription renewal orders. Can be set as true/false/0/1.</td></tr><tr><td><code>Discount</code></td><td><strong>Required (object)</strong><br>Discount definition object, details below:</td></tr><tr><td><code>Discount.Type</code></td><td><strong>Required (string)</strong><br>Type of discount. Can be FIXED or PERCENT.</td></tr><tr><td><code>Discount.Value</code></td><td><strong>Required (integer)</strong><br>Percentage discount value (PERCENT discount only).</td></tr><tr><td><code>Discount.Values</code></td><td><strong>Required (array of objects)</strong><br>List of currency discounts (FIXED discount only), details below:</td></tr><tr><td><code>Discount.Values.Currency</code></td><td><strong>Required (string)</strong><br>Code of Currency for the related amount.</td></tr><tr><td><code>Discount.Values.Amount</code></td><td><strong>Required (integer)</strong><br>Discount amount value for the related currency.</td></tr><tr><td><code>Discount.DefaultCurrency</code></td><td><strong>Required (string)</strong><br>Code of default Currency (FIXED discount only).</td></tr><tr><td><code>PrimaryProduct</code></td><td><strong>Required (object)</strong><br>Main (primary) product object, details below:</td></tr><tr><td><code>PrimaryProduct.Code</code></td><td><strong>Required (string)</strong><br>The code of the product that the recommendation is made for.</td></tr><tr><td><code>PrimaryProduct.Quantity</code></td><td><strong>Required (integer)</strong><br>The quantity for the primary product. Can be 0 (standing for any quantity).</td></tr><tr><td><code>PrimaryProduct.PriceOptions</code></td><td><strong>Optional (array of objects)</strong><br>Price options list for the primary product, details below:</td></tr><tr><td><code>PrimaryProduct.PriceOptions.Code</code></td><td><strong>Required (string)</strong><br>Price option group code.</td></tr><tr><td><code>PrimaryProduct.PriceOptions.Options</code></td><td><strong>Optional (array of objects)</strong><br>Price options list, details below:</td></tr><tr><td><code>PrimaryProduct.PriceOptions.Options.Code</code></td><td><strong>Required (string)</strong><br>Price option code.</td></tr><tr><td><code>PrimaryProduct.PriceOptions.Options.Value</code></td><td><strong>Optional (integer)</strong><br>Price option value (for scale interval price option group only).</td></tr><tr><td><code>RecommendedProduct</code></td><td><strong>Required (object)</strong><br>Recommended product object, details below:</td></tr><tr><td><code>RecommendedProduct.Code</code></td><td><strong>Required (string)</strong><br>The code of the recommended product.</td></tr><tr><td><code>RecommendedProduct.Quantity</code></td><td><strong>Required (integer)</strong><br>The quantity for the recommended product. Can be 0 (standing for “match quantity” setting).</td></tr><tr><td><code>RecommendedProduct.PriceOptions</code></td><td><strong>Optional (array of objects)</strong><br>Price options list for the recommended product, details below:</td></tr><tr><td><code>RecommendedProduct.PriceOptions.Code</code></td><td><strong>Required (string)</strong><br>Price option group code.</td></tr><tr><td><code>RecommendedProduct.PriceOptions.Options</code></td><td><strong>Optional (array of objects)</strong><br>Price options list, details below:</td></tr><tr><td><code>RecommendedProduct.PriceOptions.Options.Code</code></td><td><strong>Required (string)</strong><br>Price option code.</td></tr><tr><td><code>RecommendedProduct.PriceOptions.Options.Value</code></td><td><strong>Optional (integer)</strong><br>Price option value (for scale interval price options group only).</td></tr><tr><td><code>Enabled</code></td><td><strong>Required (boolean/integer)</strong><br>Sets the campaign enabled or disabled. Can be set as true/false/0/1.</td></tr><tr><td><code>Description</code></td><td><strong>Required (array of objects)</strong><br>List of campaign language descriptions, details below:</td></tr><tr><td><code>Description.Language</code></td><td><strong>Required (string)</strong><br>Code of the language.</td></tr><tr><td><code>Description.Text</code></td><td><strong>Required (string)</strong><br>The text of the description in the associated language.</td></tr></tbody></table>

### Request sample

```php
<?php
require ('PATH_TO_AUTH');

$upsell = new \stdClass();

$upsellCode = 'fc580e11-09e4-483f-b73e-cd0f460bcd9d';

$upsell->Name = 'December 2020 upsell campaign’;
$upsell->StartDate = '2020-12-21';
$upsell->EndDate = '2020-12-25';
$upsell->DisplayForManualRenewals = false;

// setup percent discount
$discountPercent = new \stdClass();
$discountPercent->Type = 'PERCENT';
$discountPercent->Value = 5;

// setup fixed discount
$discountFixed = new \stdClass();
$discountFixed->Type = 'FIXED';
$discountValues = [
    'USD' => 10,
    'EUR' => 8,
    'TRY' => 80,
    'RUB' => 1100,
];
$dv = [];
foreach ($discountValues as $curr => $amt) {
    $disc = new \stdClass();
    $disc->Currency = $curr;
    $disc->Amount = $amt;

    $dv[] = $disc;
}
$discountFixed->Values = $dv;

// assign discount
$upsell->Discount = $discountPercent;
# OR
# $upsell->Discount = $discountFixed;


// setup primary product
$primaryProduct = new \stdClass();
$primaryProduct->Code = $productCode;
$primaryProduct->Quantity = 1;
$ppPriceOptionGroup1 = new \stdClass();
$ppPriceOptionGroup1->Code = 'OPTGRP2';
$ppPriceOptionGroup1Option = new \stdClass();
$ppPriceOptionGroup1Option->Code = 'OptGrp2Code2';
$ppPriceOptionGroup1->Options = [$ppPriceOptionGroup1Option];

$ppPriceOptionGroup2 = new \stdClass();
$ppPriceOptionGroup2->Code = 'interval_scale_grp1';
$ppPriceOptionGroup2Option = new \stdClass();
$ppPriceOptionGroup2Option->Code = 'interval_scale_grp1-1-10';
$ppPriceOptionGroup2Option->Value = '6';
$ppPriceOptionGroup2->Options = [$ppPriceOptionGroup2Option];

$primaryProduct->PriceOptions = [$ppPriceOptionGroup1, $ppPriceOptionGroup2];
$upsell->PrimaryProduct = $primaryProduct;

// setup recommended product
$recommProduct = new \stdClass();
$recommProduct->Code = $recProductCode;
$recommProduct->Quantity = 0; // stands for “match quantity” 
$rpPriceOptionGroup1 = new \stdClass();
$rpPriceOptionGroup1->Code = 'CHECKB_LIST';
$rpPriceOptionGroup1Option1 = new \stdClass();
$rpPriceOptionGroup1Option1->Code = 'chk1';
$rpPriceOptionGroup1Option2 = new \stdClass();
$rpPriceOptionGroup1Option2->Code = 'chk3';
$rpPriceOptionGroup1->Options = [$rpPriceOptionGroup1Option1, $rpPriceOptionGroup1Option2];
$recommProduct->PriceOptions = [$rpPriceOptionGroup1];
$upsell->RecommendedProduct = $recommProduct;

$upsell->Enabled = true;

// setup languagte descriptions / texts
$enDescription = new \stdClass();
$enDescription->Language = 'EN';
$enDescription->Text = 'Buy <!--{RECOMMENDED_PRODUCT_NAME}--> for just <!--{RECOMMENDED_PRODUCT_PRICE}--> until Dec 25th';
$upsell->Description = [$enDescription];

$jsonRpcRequest = new \stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'updateUpsellCampaign';
$jsonRpcRequest->params = [$sessionID, $upsellCode, $upsell];
$jsonRpcRequest->id = $i++;

$upsellResponse = callRPC($jsonRpcRequest, $host);
```

## Response parameters

<table><thead><tr><th width="124.4000244140625">Parameters</th><th>Type / Description</th></tr></thead><tbody><tr><td><a href="/pages/1a7741866b1eaedfee943ee450d04ecaabd287bc"><code>UpSell</code></a></td><td><p><strong>Object</strong></p><p>Object containing information related to the upsell campaigns, including product information and discount settings.</p></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/upsell/update-upsell-campaign.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
