> For the complete documentation index, see [llms.txt](https://docs.2checkout.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/cross-sell/search-cross-sell-campaigns.md).

# Search cross-sell campaigns

Use the **searchCrossSellCampaigns** call to retrieve information on the cross-sell campaigns currently defined on your account.

## Request parameters

<table><thead><tr><th width="192.6666259765625">Parameters</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>CampaignName</code></td><td><p><strong>Optional (string)</strong></p><p>The name of the campaign.</p></td></tr><tr><td><code>Status</code></td><td><p><strong>Optional (string)</strong></p><p>The status of the campaign; can be ACTIVE/INACTIVE.</p></td></tr><tr><td><code>Products</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of product codes to apply to this campaign.</p></td></tr><tr><td><code>RecommendedProducts</code></td><td><p><strong>Optional (array of strings)</strong></p><p>Array of product codes recommended to the shopper.</p></td></tr><tr><td><code>StartDate</code></td><td><p><strong>Optional (string)</strong></p><p>The date when the cross-sell campaign starts, formatted as YYYY-MM-DD</p></td></tr><tr><td><code>EndDate</code></td><td><p><strong>Optional (string)</strong></p><p>The date when the cross-sell campaign ends, formatted as YYYY-MM-DD</p></td></tr><tr><td><code>Type</code></td><td><p><strong>Optional (string)</strong></p><p>Can be MERCH/AFF.</p></td></tr><tr><td><code>Pagination</code></td><td><strong>Optional (object)</strong></td></tr><tr><td><code>Page</code></td><td><p><strong>Optional (int)</strong></p><p>The page number of the results.</p></td></tr><tr><td><code>Limit</code></td><td><p><strong>Optional (int)</strong></p><p>The number of results per page.</p></td></tr></tbody></table>

### Request sample

```php
<?php
declare(strict_types=1);

// Start clear CLI
echo chr(27).chr(91).'H'.chr(27).chr(91).'J';
// End clear CLI

$executionStartTime = microtime(true);

class Configuration
{
    public const MERCHANT_CODE = 'your_merchant_code';
    public const MERCHANT_KEY = 'your_merchant_key';

    public const URL = 'http://api.avangate.local/rpc/6.0';
}

class Client
{
    private const LOGIN_METHOD = 'login';
    private const SEARCH_CROSS_SELL_CAMPAIGNS = 'searchCrossSellCampaigns';

    private int $calls = 1;

    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);

        return compact('merchantCode', 'date', 'hash');
    }

    public function login()
    {
        $payload = $this->generateAuth();
        $response = $this->callForRpc(Configuration::URL, self::LOGIN_METHOD, array_values($payload));

        return $response['result'];
    }

    private function callForRpc(string $url, string $action, ?array $payload = null)
    {
        $request = json_encode([\
            'jsonrpc' => '2.0',\
            'method' => $action,\
            'params' => $payload,\
            'id' => $this->calls++,\
        ]);

        $headers = [\
            'Content-Type: application/json',\
            'Accept: application/json',\
            'Cookie: XDEBUG_SESSION=PHPSTORM'\
        ];

        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if (empty($response)) {
            die('Server unavailable');
        }

        echo "\n\r Method " . $action . " result: \n\r";
        echo $response . "\n\r";

        return json_decode($response, true);
    }

    private function buildSearchParameters(): array
    {
        $searchOptions = new \stdClass();

        $searchOptions->Status = ['ACTIVE'];     // Optional | Ex: ['ACTIVE']
        $searchOptions->Type = null;             // Optional | Ex: 'MERCH'
        $searchOptions->CampaignName = null;     // Optional | Ex: 'UpdatedCampaign_4'
        $searchOptions->Products = [];           // Optional | Ex: ["a01", "a02"]
        $searchOptions->RecommendedProducts = [];// Optional | Ex: ["a03"]
        $searchOptions->StartDate = null;        // Optional | Ex: 'YYYY-MM-DD'
        $searchOptions->EndDate = null;          // Optional | Ex: 'YYYY-MM-DD'
        $searchOptions->Pagination = null;       // Optional | Ex: {"Page": "1", "Limit": "10"}

        return (array)$searchOptions;
    }

    public function searchCrossSellCampaigns($sessionId)
    {
        $response = $this->callForRpc(
            Configuration::URL,
            self::SEARCH_CROSS_SELL_CAMPAIGNS,
            [$sessionId, $this->buildSearchParameters()]
        );

        return $response['result'];
    }
}

$client = new Client();

$sessionId = $client->login();

$result = $client->searchCrossSellCampaigns($sessionId);
var_dump("SEARCH CROSS SELL CAMPAIGNS: \n\r", json_encode($result, JSON_PRETTY_PRINT));

$executionEndTime = microtime(true);

// The duration will be displayed in seconds and milliseconds.
$seconds = round($executionEndTime - $executionStartTime, 2);

// Print it out
echo "\n\rThis script took $seconds to execute.\n\r";
```

## Response parameters

<table><thead><tr><th width="137.2000732421875">Parameters</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>Items</code></td><td>An array of <a href="/pages/d1ef2dba007a2eaea091f8bdd531bb1e1a9b64cf">CrossSellCampaign</a> objects</td></tr><tr><td><code>Pagination</code></td><td>Pagination object with the following parameters: <code>Page</code>, <code>Limit</code>, <code>Count</code></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/cross-sell/search-cross-sell-campaigns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
