> 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/subscription-upgrade/upgrade-subscription.md).

# Upgrade subscription

Use the **setSubscriptionUpgrade** method to upgrade a subscription.

## Requirements

You can only upgrade subscriptions with automatic renewal **enabled**.

{% hint style="warning" %}
The upgrade will not work if the subscription has a refund request that was not yet processed.
{% endhint %}

{% hint style="warning" %}

### Upgrading subscriptions with addons

**Addon subscriptions cannot be upgraded directly. To change an addon, upgrade its main subscription. If the product you upgrade to has a different associated addon, 2Checkout swaps the addon automatically as part of the same upgrade.**
{% endhint %}

### **Request parameters**

<table><thead><tr><th width="215.066650390625">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>sessionID</code></td><td><strong>Required (string)</strong><br>Session identifier, the output of the <strong>Login</strong> method. Include <code>sessionID</code> into all your requests. 2Checkout throws an exception if the values are incorrect. The <code>sessionID</code> expires in <strong>10 minutes</strong>.</td></tr><tr><td><code>subscriptionReference</code></td><td><strong>Required (string)</strong><br>Unique, system-generated subscription identifier.</td></tr><tr><td><code>productCode</code></td><td><strong>Required (string)</strong><br>Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel.</td></tr><tr><td><code>options</code></td><td><strong>Optional (string)</strong><br>Pricing options of the target product for the subscription upgrade process.<br>String — ';' separated list of <code>OptionValue</code> returned by <strong>getProductUpgradeOptions</strong> function.<br>If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value<br>e.g. Users=7</td></tr><tr><td><code>customPrice</code></td><td><strong>Optional (string)</strong><br>The price you want to charge customers for the upgrade. <strong>The currency used by default is the same as in the previous payment customers made.</strong></td></tr></tbody></table>

### Request sample

```php
<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$productCode = 'YOUR_PRODUCT_CODE';
$options = 'YOUR_PRICE_CODES'; //case sensitive; include only price options codes (exclude spaces)
$customPrice = 1;

$jsonRpcRequest = array (
  'method' => 'setSubscriptionUpgrade',
  'params' => array($sessionID, $subscriptionReference, $productCode, $options, $customPrice),
  'id' => $i++,
  'jsonrpc' => '2.0'
);

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
```

## Response parameters

<table><thead><tr><th width="110.5333251953125">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Boolean</strong></td><td><strong>true</strong> or <strong>false</strong> depending on whether or not the operation succeeded.</td></tr></tbody></table>

## **Error codes**

| Error code                             | Description                             |
| -------------------------------------- | --------------------------------------- |
| **ADDON\_UPGRADE\_INVALID\_OPERATION** | Addon subscriptions cannot be upgraded. |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.2checkout.com/json-rpc-api-reference/json-rpc-api-6.0/api-requests/subscription-upgrade/upgrade-subscription.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
