# POST /subscription/{{subscription_id}}/update_charges — Subscription Update Charges

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

This link will be fired with POST 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. |
| quantity | string | No | Add the quantity of the plan for which you want to subscribe to your customer. |
| price | string | No | Add the price of the plan for which you want to subscribe to your customer. |
| coupon_code | string | No | Unique coupon code of the plan which you will assign to this 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 |

**Example request body:**

```json
{
    "plan_id": "61811ba89764a44a4cae8986",//Required
    "coupon_code": "ltd",
    "setup_fee": "10",
    "addons": [
        {
            "id": "6188d46e3a5dad46546547fa",
            "quantity": 2
        }
    ],
    "quantity": 2,
    "price": "150.00"
}
```

**Response (200)** — Subscription Update Charges:

```json
{
    "status": "success",
    "message": "Upgrade downgrade charges",
    "data": {
        "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_quantity": 2,
        "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": []
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "plan_id": "{{plan_id}}"
  }'
```

_Ruby_

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

uri = URI('https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges')
request = Net::HTTP::Post.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"plan_id\":\"{{plan_id}}\"}"

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.post(
    'https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'plan_id': '{{plan_id}}'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
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":"{{plan_id}}"}');

$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}}/update_charges"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"plan_id\":\"{{plan_id}}\"}"));

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}}/update_charges', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "plan_id": "{{plan_id}}"
  }),
});

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

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"plan_id\":\"{{plan_id}}\"}")
    req, _ := http.NewRequest("POST", "https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges", 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.Post, "https://payments.pabbly.com/api/v1/subscription/{{subscription_id}}/update_charges");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"plan_id\":\"{{plan_id}}\"}");
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)
- [PUT /subscription/{{subscription_id}}/upgrade-downgrade — Upgrade Downgrade Subscription](/subscription-billing/subscriptions/upgrade-downgrade-subscription)
- [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)

