# PUT /subscription/{{subscription_id}}/upgrade-downgrade — Upgrade Downgrade Subscription

> Product: **Pabbly Subscription Billing** (v1)
> Base URL: `https://payments.pabbly.com/api/v1`
> Auth: Basic via `Authorization` header
> Canonical: `/subscription-billing/subscriptions/upgrade-downgrade-subscription`

This link will be fired with PUT request. You will need to add the existing subscription Id in the Request URL

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| subscription_id | string | Yes |  |

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| plan_id | string | Yes | Unique Id of the plan which you will assign to this customer. |
| customer_id | string | No |  |
| payment_term | string | No | Possible values of payment_term are net0/net15/net30/net45/net60/neteom/neteonm. If this attribute is not used then net0 will be the default value. |
| activated_at_val | string | No | Apply the changes immediately or at end of the term. immediately - If you want to apply the changes immediately. eot (End of the term) - If you want to apply the changes at the end of the term. |
| card_id | string | No | If you want to charge from different method, provide payment method id. |
| payment_mode | string | Yes | Possible value will be offline or credit_card |
| coupon_code | string | No | This code will be used by the customer to avail discounts. |
| price | string | No | Add the amount of the plan |
| quantity | string | No | Add the quantity of the plan for which you want to subscribe to your customer. |
| setup_fee | string | No | Add the setup fee amount of the plan for which you want to subscribe to your customer. |
| addons | string | No | Add the addon IDs & addon quantities |
| update_reason | string | No | Add the subscription update reason that will be displayed in the single subscription page. |

**Example request body:**

```json
{
   "plan_id": "5e3aa7133c92e44b424b6dec",
   "customer_id": "5e5e2bca815f5442a4208dfe",
   "payment_term": "net0",
   "activated_at_val": "immediately"
}
```

**Response (200)** — Upgrade Downgrade Subscription:

```json
{
    "status": "success",
    "message": "Subscription updated successfully",
    "data": {
        "user": {
            "verified": "1",
            "currency": "USD",
            "createdAt": "2020-12-21T10:02:54.714Z",
            "updatedAt": "2021-11-29T09:46:07.887Z",
            "id": "5fe072ce5c9d8f083aae9e13",
            "first_name": "Satish",
            "last_name": "Thapa",
            "email": "satishthapa00@gmail.com",
            "address_line1": "",
            "address_line2": "",
            "city": "",
            "state": "",
            "country": "",
            "zip_code": "",
            "phone": "5555555555",
            "mobile": "",
            "facebook_url": "",
            "twitter_url": "",
            "time_zone": "Asia/Kolkata",
            "date_format": "YYYY/MM/DD hh:mm A",
            "ip_address": "171.61.54.154",
            "currency_symbol": "$"
        },
        "customer": {
            "billing_address": {
                "street1": "Street",
                "city": "City",
                "state": "Prickly Pear Cays",
                "state_code": "13",
                "zip_code": "1234",
                "country": "AI"
            },
            "shipping_address": {},
            "createdAt": "2021-12-14T11:20:29.539Z",
            "updatedAt": "2021-12-14T11:20:29.539Z",
            "id": "61b87dfd652e9b3eac440e64",
            "first_name": "test",
            "last_name": "ing",
            "email_id": "leg-test-80@inboxkitten.com",
            "credit": null
        },
        "product": {
            "createdAt": "2021-11-02T11:04:19.021Z",
            "updatedAt": "2021-11-02T11:04:19.021Z",
            "id": "61811b339764a44a4cae8985",
            "product_name": "test",
            "description": null,
            "redirect_url": null
        },
        "plan": {
            "plan_active": "true",
            "createdAt": "2021-11-02T11:06:16.212Z",
            "updatedAt": "2021-12-13T11:45:48.240Z",
            "id": "61811ba89764a44a4cae8986",
            "product_id": "61811b339764a44a4cae8985",
            "plan_name": "test",
            "plan_code": "test",
            "price": 150,
            "billing_period": "m",
            "billing_period_num": "1",
            "billing_cycle": "lifetime",
            "billing_cycle_num": "",
            "trial_period": 0,
            "setup_fee": 10,
            "plan_description": "<p><img src=\"https://s3-us-west-2.amazonaws.com/pabbly/product/images/2021/11/RM7tVNdIE9Vs-1636808533-dummy-image.jpg\"></p>"
        },
        "subscription": {
            "plan": {
                "plan_active": "true",
                "createdAt": "2021-11-02T11:06:16.212Z",
                "updatedAt": "2021-12-13T11:45:48.240Z",
                "id": "61811ba89764a44a4cae8986",
                "product_id": "61811b339764a44a4cae8985",
                "plan_name": "test",
                "plan_code": "test",
                "price": 150,
                "billing_period": "m",
                "billing_period_num": "1",
                "billing_cycle": "lifetime",
                "billing_cycle_num": "",
                "trial_period": 0,
                "setup_fee": 10,
                "plan_description": "<p><img src=\"https://s3-us-west-2.amazonaws.com/pabbly/product/images/2021/11/RM7tVNdIE9Vs-1636808533-dummy-image.jpg\"></p>"
            },
            "setup_fee": 10,
            "payment_terms": "",
            "currency_symbol": "$",
            "payment_method": "61b87dff652e9b3eac440e68",
            "taxable": true,
            "gateway_type": "test",
            "gateway_id": "61811b149764a44a4cae8984",
            "custom_fields": [],
            "addons": [
                {
                    "id": "6188d3e73a5dad46546547f8",
                    "name": "test",
                    "product_id": "61811b339764a44a4cae8985",
                    "code": "test",
                    "price": 50,
                    "quantity": 2,
                    "billing_cycle": "onetime",
                    "billing_period": "",
                    "associate_plans": "all_plans",
                    "plans_array": null,
                    "category_array": [
                        "uncategory"
                    ],
                    "adjusted_amount": 50
                },
                {
                    "id": "6188d46e3a5dad46546547fa",
                    "name": "test1",
                    "product_id": "61811b339764a44a4cae8985",
                    "code": "test1",
                    "price": 100,
                    "quantity": 1,
                    "billing_cycle": "lifetime",
                    "billing_period": "m",
                    "associate_plans": "all_plans",
                    "plans_array": null,
                    "category_array": [
                        "uncategory"
                    ],
                    "adjusted_amount": 100
                }
            ],
            "coupon": {
                "status": "active",
                "apply_to": "total_amount",
                "createdAt": "2021-12-10T08:04:26.518Z",
                "updatedAt": "2021-12-14T08:27:54.368Z",
                "id": "61b30a0a004ed42d0c313916",
                "product_id": "61811b339764a44a4cae8985",
                "coupon_name": "ltd",
                "coupon_code": "ltd",
                "discount": 10,
                "discount_type": "percent",
                "redemption_type": "number_time",
                "redemption_cycle": 10,
                "associate_plans": "all_plans",
                "plans_array": null,
                "valid_upto": "2022-01-01",
                "maximum_redemption": 10000,
                "used_redemption": 23
            },
            "update_reason": "test",
            "update_type": "upgrade",
            "createdAt": "2021-12-14T11:20:29.570Z",
            "updatedAt": "2021-12-14T11:20:46.724Z",
            "id": "61b87dfd652e9b3eac440e65",
            "customer_id": "61b87dfd652e9b3eac440e64",
            "product_id": "61811b339764a44a4cae8985",
            "plan_id": "61811ba89764a44a4cae8986",
            "amount": 150,
            "email_id": "leg-test-80@inboxkitten.com",
            "status": "live",
            "quantity": 2,
            "starts_at": "2021-12-14T11:20:29.292Z",
            "activation_date": "2021-12-14T11:20:32.323Z",
            "expiry_date": "2121-12-14T11:20:29.292Z",
            "trial_days": 0,
            "trial_expiry_date": "",
            "next_billing_date": "2022-01-14T11:20:32.323Z",
            "last_billing_date": "2021-12-14T11:20:32.323Z",
            "canceled_date": null
        },
        "invoice": {
            "quantity": "2",
            "product_id": "61811b339764a44a4cae8985",
            "setup_fee": 20,
            "currency_symbol": "$",
            "credit_note": {
                "total_tax": "0.00",
                "current_plan_name": "test",
                "current_plan_price": 100,
                "current_plan_quantity": 1,
                "current_plan_total": 100,
                "new_plan_price": 150,
                "new_plan_name": "test",
                "new_plan_total": "468.00",
                "used_amount": 0,
                "update_type": "upgrade",
                "used_days": 0,
                "remaining_days": 30,
                "new_credits": 100,
                "transaction_note": "Added During Upgrade",
                "total_credit_amount": 100,
                "charge_amount": 368,
                "credit_applied": [
                    {
                        "id": "61b87e0b652e9b3eac440e6c",
                        "amount": 100,
                        "deducted_from": 100,
                        "remaining_amount": 0
                    }
                ]
            },
            "tax_apply": {
                "country": "AI",
                "tax_id": "",
                "exempt_tax": [],
                "total_amount": 468,
                "total_tax": "0.00"
            },
            "createdAt": "2021-12-14T11:20:43.502Z",
            "updatedAt": "2021-12-14T11:20:46.731Z",
            "id": "61b87e0b652e9b3eac440e6e",
            "customer_id": "61b87dfd652e9b3eac440e64",
            "subscription_id": "61b87dfd652e9b3eac440e65",
            "status": "paid",
            "invoice_id": "INV-299",
            "payment_term": "",
            "amount": 468,
            "due_amount": 0,
            "due_date": "2021-12-14T11:20:43.434Z",
            "subscription": {
                "plan": {
                    "plan_active": "true",
                    "createdAt": "2021-11-02T11:06:16.212Z",
                    "updatedAt": "2021-12-13T11:45:48.240Z",
                    "id": "61811ba89764a44a4cae8986",
                    "product_id": "61811b339764a44a4cae8985",
                    "plan_name": "test",
                    "plan_code": "test",
                    "price": 150,
                    "billing_period": "m",
                    "billing_period_num": "1",
                    "billing_cycle": "lifetime",
                    "billing_cycle_num": "",
                    "trial_period": 0,
                    "setup_fee": 10,
                    "plan_description": "<p><img src=\"https://s3-us-west-2.amazonaws.com/pabbly/product/images/2021/11/RM7tVNdIE9Vs-1636808533-dummy-image.jpg\"></p>"
                },
                "setup_fee": 10,
                "payment_terms": "",
                "currency_symbol": "$",
                "payment_method": "61b87dff652e9b3eac440e68",
                "taxable": true,
                "gateway_type": "test",
                "gateway_id": "61811b149764a44a4cae8984",
                "custom_fields": [],
                "addons": [
                    {
                        "id": "6188d3e73a5dad46546547f8",
                        "name": "test",
                        "product_id": "61811b339764a44a4cae8985",
                        "code": "test",
                        "price": 50,
                        "quantity": 2,
                        "billing_cycle": "onetime",
                        "billing_period": "",
                        "associate_plans": "all_plans",
                        "plans_array": null,
                        "category_array": [
                            "uncategory"
                        ],
                        "adjusted_amount": 50
                    },
                    {
                        "id": "6188d46e3a5dad46546547fa",
                        "name": "test1",
                        "product_id": "61811b339764a44a4cae8985",
                        "code": "test1",
                        "price": 100,
                        "quantity": 1,
                        "billing_cycle": "lifetime",
                        "billing_period": "m",
                        "associate_plans": "all_plans",
                        "plans_array": null,
                        "category_array": [
                            "uncategory"
                        ],
                        "adjusted_amount": 100
                    }
                ],
                "coupon": {
                    "status": "active",
                    "apply_to": "total_amount",
                    "createdAt": "2021-12-10T08:04:26.518Z",
                    "updatedAt": "2021-12-14T08:27:54.368Z",
                    "id": "61b30a0a004ed42d0c313916",
                    "product_id": "61811b339764a44a4cae8985",
                    "coupon_name": "ltd",
                    "coupon_code": "ltd",
                    "discount": 10,
                    "discount_type": "percent",
                    "redemption_type": "number_time",
                    "redemption_cycle": 10,
                    "associate_plans": "all_plans",
                    "plans_array": null,
                    "valid_upto": "2022-01-01",
                    "maximum_redemption": 10000,
                    "used_redemption": 23
                },
                "update_reason": "test",
                "update_type": "upgrade",
                "createdAt": "2021-12-14T11:20:29.570Z",
                "updatedAt": "2021-12-14T11:20:46.724Z",
                "id": "61b87dfd652e9b3eac440e65",
                "customer_id": "61b87dfd652e9b3eac440e64",
                "product_id": "61811b339764a44a4cae8985",
                "plan_id": "61811ba89764a44a4cae8986",
                "amount": 150,
                "email_id": "leg-test-80@inboxkitten.com",
                "status": "live",
                "quantity": 2,
                "starts_at": "2021-12-14T11:20:29.292Z",
                "activation_date": "2021-12-14T11:20:32.323Z",
                "expiry_date": "2121-12-14T11:20:29.292Z",
                "trial_days": 0,
                "trial_expiry_date": "",
                "next_billing_date": "2022-01-14T11:20:32.323Z",
                "last_billing_date": "2021-12-14T11:20:32.323Z",
                "canceled_date": null
            }
        }
    }
}

```

**Code examples:**

_cURL_

```curl
curl -X PUT https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "plan_id": "5e3aa7133c92e44b424b6dec",
    "customer_id": "5e5e2bca815f5442a4208dfe",
    "payment_term": "net0",
    "activated_at_val": "immediately"
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade')
request = Net::HTTP::Put.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"plan_id\":\"5e3aa7133c92e44b424b6dec\",\"customer_id\":\"5e5e2bca815f5442a4208dfe\",\"payment_term\":\"net0\",\"activated_at_val\":\"immediately\"}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests
from requests.auth import HTTPBasicAuth

response = requests.put(
    'https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'plan_id': '5e3aa7133c92e44b424b6dec',
    'customer_id': '5e5e2bca815f5442a4208dfe',
    'payment_term': 'net0',
    'activated_at_val': 'immediately'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_USERPWD, '{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"plan_id":"5e3aa7133c92e44b424b6dec","customer_id":"5e5e2bca815f5442a4208dfe","payment_term":"net0","activated_at_val":"immediately"}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;

String credentials = Base64.getEncoder().encodeToString("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}".getBytes());

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString("{\"plan_id\":\"5e3aa7133c92e44b424b6dec\",\"customer_id\":\"5e5e2bca815f5442a4208dfe\",\"payment_term\":\"net0\",\"activated_at_val\":\"immediately\"}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const credentials = Buffer.from('{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}').toString('base64');

const response = await fetch('https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "plan_id": "5e3aa7133c92e44b424b6dec",
    "customer_id": "5e5e2bca815f5442a4208dfe",
    "payment_term": "net0",
    "activated_at_val": "immediately"
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"plan_id\":\"5e3aa7133c92e44b424b6dec\",\"customer_id\":\"5e5e2bca815f5442a4208dfe\",\"payment_term\":\"net0\",\"activated_at_val\":\"immediately\"}")
    req, _ := http.NewRequest("PUT", "https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade", payload)
    req.Header.Set("Content-Type", "application/json")
    req.SetBasicAuth("{{YOUR_API_KEY}}", "{{YOUR_SECRET_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}"));

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/upgrade-downgrade");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"plan_id\":\"5e3aa7133c92e44b424b6dec\",\"customer_id\":\"5e5e2bca815f5442a4208dfe\",\"payment_term\":\"net0\",\"activated_at_val\":\"immediately\"}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Subscriptions:**

- [POST /subscription/{{customer_id}} — Create Subscription For Existing Customer](/subscription-billing/subscriptions/create-subscription-for-existing-customer)
- [POST /subscription/{{subscription_id}}/cancel — Cancel Subscription For Existing Customer](/subscription-billing/subscriptions/cancel-subscription-for-existing-customer)
- [GET /subscription/{{subscription_id}} — Get Single Subscription](/subscription-billing/subscriptions/get-single-subscription)
- [GET /subscriptions/{{customer_id}} — List All Subscriptions By Customer Id](/subscription-billing/subscriptions/list-all-subscriptions-by-customer-id)
- [GET /subscriptions — List All Subscriptions](/subscription-billing/subscriptions/list-all-subscriptions)
- [GET /scheduledchanges/{{suscription_id}} — Get Scheduled Subscription](/subscription-billing/subscriptions/get-scheduled-subscription)
- [POST /subscription/{{subscription_id}}/update_charges — Subscription Update Charges](/subscription-billing/subscriptions/subscription-update-charges)
- [DELETE /subscriptions/{{subscription_id}} — Delete Subscription](/subscription-billing/subscriptions/delete-subscription)
- [PUT /subscription/change-billing/{{subscription_id}} — Change Subscription Billing Date](/subscription-billing/subscriptions/change-subscription-billing-date)
- [PUT /subscription/{{subscription_id}}/update — Update Subscription](/subscription-billing/subscriptions/update-subscription)
- [PUT /subscription/{{subscription_id}}/pause — Pause Subscription](/subscription-billing/subscriptions/pause-subscription)
- [PUT /subscription/{{subscription_id}}/resume — Resume Subscription](/subscription-billing/subscriptions/resume-subscription)

