# Search upsell campaigns

Use the **searchUpsellCampaigns** method via JSON-RPC API 6.0 to find and filter specific upsell campaigns.

## Request parameters

<table><thead><tr><th width="227.86669921875">Parameter Name</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>SessionId</code></td><td><p><strong>Required (string)</strong></p><p>Unique 2Checkout session ID code.</p></td></tr><tr><td><code>Name</code></td><td><p><strong>Optional (string)</strong></p><p>Title of the campaign.</p></td></tr><tr><td><code>PrimaryProductCodes</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of product codes used as primary products you want to filter by.</p></td></tr><tr><td><code>PrimaryProductCode</code></td><td><p><strong>Optional (string)</strong></p><p>Unique product code.</p></td></tr><tr><td><code>RecommendedProductCodes</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of product codes used as recommended products you want to filter by.</p></td></tr><tr><td><code>RecommendedProductCode</code></td><td><p><strong>Optional (string)</strong></p><p>Unique product code.</p></td></tr><tr><td><code>Statuses</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of statuses you want to filter by.</p></td></tr><tr><td><code>Status</code></td><td><p><strong>Optional (string)</strong></p><p>Status of the upsell campaign. Enum can be one of: Enabled, Disabled, Expired</p></td></tr><tr><td><code>StartsAfter</code></td><td><p><strong>Optional (string)</strong></p><p>Date in ‘Y-m-d’ format after which campaigns start.</p></td></tr><tr><td><code>StartsBefore</code></td><td><p><strong>Optional (string)</strong></p><p>Date in ‘Y-m-d’ before campaigns start.</p></td></tr><tr><td><code>EndsAfter</code></td><td><p><strong>Optional (string)</strong></p><p>Date in ‘Y-m-d’ after which campaigns are ending.</p></td></tr><tr><td><code>EndsBefore</code></td><td><p><strong>Optional (string)</strong></p><p>Date in ‘Y-m-d’ before campaigns end.</p></td></tr><tr><td><code>EnabledForRenewals</code></td><td><p><strong>Optional (boolean)</strong></p><p>Filter campaigns enabled for renewal.</p></td></tr><tr><td><code>CampaignCodes</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of campaign codes to filter by.</p></td></tr><tr><td><code>CampaignCode</code></td><td><p><strong>Optional (string)</strong></p><p>Unique code for an upsell campaign.</p></td></tr><tr><td><code>Page</code></td><td><p><strong>Optional (integer)</strong></p><p>Page you want to retrieve.</p></td></tr><tr><td><code>Limit</code></td><td><p><strong>Optional (integer)</strong></p><p>Maximum number of campaigns per page.</p></td></tr></tbody></table>

### Request sample

```php
<?php
 
require ('PATH_TO_AUTH');
 
$filters = new \stdClass();
$filters->Name = 'op_2';
$filters->PrimaryProductCodes = ['A59VUKFMA2', 'JN2GSQ184L'];
$filters->RecommendedProductCodes = ['XI2MNQ41MNH'];
$filters->Statuses = ['DISABLED', 'EXPIRED'];
$filters->StartsBefore = '2020-10-01';
$filters->StartsAfter = '2019-11-05';
$filters->EndsBefore = '2022-11-10';
$filters->EndsAfter = '2020-10-02';
//$filters->EnabledForRenewals = true;
//$filters->CampaignCodes = ['8050a1b7-338e-45bd-9936-17f98b01349e'];
$filters->Page = 1;
$filters->Limit = 10;
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'searchUpsellCampaigns';
$jsonRpcRequest->params = array($sessionID, $filters);
$jsonRpcRequest->id = $i++;
 
try {
    $result = callRPC($jsonRpcRequest, $host);
    echo "Campaigns: </br>",
    var_dump($result);
}
catch (SoapFault $e) {
    echo "Could not fetch upsell campaigns: " . $e->getMessage();
    exit;
}
```

## Response parameters

| Parameter                                                                                     | Type / Description                                                                                          |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `Page`                                                                                        | <p><strong>Required (integer)</strong></p><p>The <em>Search</em> page you are on.</p>                       |
| `Limit`                                                                                       | <p><strong>Required (integer)</strong></p><p>Maximum number of campaigns per page.</p>                      |
| `Upsells`                                                                                     | <p><strong>Required (array of strings)</strong></p><p>Array of Upsell Campaigns.</p>                        |
| `Upsells.`[`UpsellCampaign`](/json-rpc-api-reference/json-rpc-api-6.0/api-requests/upsell.md) | **Required (object)**                                                                                       |
| `UpsellsCount`                                                                                | <p><strong>Required (integer)</strong></p><p>Total number of Upsells that fit your search criteria.</p>     |
| `PagesCount`                                                                                  | <p><strong>Required (integer)</strong></p><p>Total number of pages with Upsells that fit your criteria.</p> |


---

# 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/search-upsell-campaigns.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.
