# PUT /addon/{{addon_id}} — Update Addon

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

This API can be used to update the details of an existing add-on. The API will be fired with PUT request along with the add-on Id in the API link. In the form data you will add all the new details for the add-on and fire it. In response you will get the update details of the existing add-on on the same add-on Id.

**Path parameters:**

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

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| name | string | No | Updated name of the add-on. |
| code | string | No | Updated code of the add-on. |
| price | integer | No | Updated price of the add-on. |
| category_array | array | No | Updated category of the add-on. |
| status | boolean | No | Updated status of the Add-on |
| associate_plans | string | No | Updated plans of the add-on |
| billing_cycle | string | No | Updated billing cycle |
| billing_period | string | No | Update billing frequency |
| billing_period_num | integer | No | Update billing frequency |
| description | string | No | Updated decription of the add-on |
| plans_array | string | No | New plan array |
| product_id | string | No | Product id with which the add-on is associated |

**Example request body:**

```json
{ 
  "name": "Updated Name",
  "code": "updated-code",
  "price": 20,
  "category_array": [ "5e3aac233c92e44b424b6dfb", "5e3aac1924b63d4b28410d4d" ],
  "status": true,
  "associate_plans": "all_plans",
  "billing_cycle": "lifetime",
  "billing_period": "m",
  "billing_period_num": 1,
  "description": "",
  "plans_array": null,
  "product_id": "5e3a95143c92e44b424b6d47"
}
```

**Response (200)** — Update Addon:

```json
{
    "status": "success",
    "message": "Addon Updated Successfully",
    "data": {
        "billing_period": "m",
        "category_array": [
            "5e3aac233c92e44b424b6dfb",
            "5e3aac1924b63d4b28410d4d"
        ],
        "createdAt": "2020-02-05T11:51:18.185Z",
        "updatedAt": "2020-02-05T11:51:18.185Z",
        "id": "5e3aac363c92e44b424b6dfc",
        "product_id": "5e3a95143c92e44b424b6d47",
        "user_id": "5b961bc55dfff7797d9cd897",
        "name": "Updated Name",
        "code": "updated-code",
        "price": 20,
        "billing_cycle": "lifetime",
        "status": false,
        "associate_plans": "all_plans",
        "plans_array": null,
        "description": ""
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X PUT https://payments.pabbly.com/api/v1/addon/{{addon_id}} \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Name",
    "code": "updated-code",
    "price": 20,
    "category_array": [
      "5e3aac233c92e44b424b6dfb",
      "5e3aac1924b63d4b28410d4d"
    ],
    "status": true,
    "associate_plans": "all_plans",
    "billing_cycle": "lifetime",
    "billing_period": "m",
    "billing_period_num": 1,
    "description": "",
    "plans_array": null,
    "product_id": "5e3a95143c92e44b424b6d47"
  }'
```

_Ruby_

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

uri = URI('https://payments.pabbly.com/api/v1/addon/{{addon_id}}')
request = Net::HTTP::Put.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"name\":\"Updated Name\",\"code\":\"updated-code\",\"price\":20,\"category_array\":[\"5e3aac233c92e44b424b6dfb\",\"5e3aac1924b63d4b28410d4d\"],\"status\":true,\"associate_plans\":\"all_plans\",\"billing_cycle\":\"lifetime\",\"billing_period\":\"m\",\"billing_period_num\":1,\"description\":\"\",\"plans_array\":null,\"product_id\":\"5e3a95143c92e44b424b6d47\"}"

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/addon/{{addon_id}}',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'name': 'Updated Name',
    'code': 'updated-code',
    'price': 20,
    'category_array': [
        '5e3aac233c92e44b424b6dfb',
        '5e3aac1924b63d4b28410d4d'
    ],
    'status': True,
    'associate_plans': 'all_plans',
    'billing_cycle': 'lifetime',
    'billing_period': 'm',
    'billing_period_num': 1,
    'description': '',
    'plans_array': None,
    'product_id': '5e3a95143c92e44b424b6d47'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/addon/{{addon_id}}');
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, '{"name":"Updated Name","code":"updated-code","price":20,"category_array":["5e3aac233c92e44b424b6dfb","5e3aac1924b63d4b28410d4d"],"status":true,"associate_plans":"all_plans","billing_cycle":"lifetime","billing_period":"m","billing_period_num":1,"description":"","plans_array":null,"product_id":"5e3a95143c92e44b424b6d47"}');

$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/addon/{{addon_id}}"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString("{\"name\":\"Updated Name\",\"code\":\"updated-code\",\"price\":20,\"category_array\":[\"5e3aac233c92e44b424b6dfb\",\"5e3aac1924b63d4b28410d4d\"],\"status\":true,\"associate_plans\":\"all_plans\",\"billing_cycle\":\"lifetime\",\"billing_period\":\"m\",\"billing_period_num\":1,\"description\":\"\",\"plans_array\":null,\"product_id\":\"5e3a95143c92e44b424b6d47\"}"));

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/addon/{{addon_id}}', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Updated Name",
    "code": "updated-code",
    "price": 20,
    "category_array": [
      "5e3aac233c92e44b424b6dfb",
      "5e3aac1924b63d4b28410d4d"
    ],
    "status": true,
    "associate_plans": "all_plans",
    "billing_cycle": "lifetime",
    "billing_period": "m",
    "billing_period_num": 1,
    "description": "",
    "plans_array": null,
    "product_id": "5e3a95143c92e44b424b6d47"
  }),
});

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

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"name\":\"Updated Name\",\"code\":\"updated-code\",\"price\":20,\"category_array\":[\"5e3aac233c92e44b424b6dfb\",\"5e3aac1924b63d4b28410d4d\"],\"status\":true,\"associate_plans\":\"all_plans\",\"billing_cycle\":\"lifetime\",\"billing_period\":\"m\",\"billing_period_num\":1,\"description\":\"\",\"plans_array\":null,\"product_id\":\"5e3a95143c92e44b424b6d47\"}")
    req, _ := http.NewRequest("PUT", "https://payments.pabbly.com/api/v1/addon/{{addon_id}}", 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/addon/{{addon_id}}");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"name\":\"Updated Name\",\"code\":\"updated-code\",\"price\":20,\"category_array\":[\"5e3aac233c92e44b424b6dfb\",\"5e3aac1924b63d4b28410d4d\"],\"status\":true,\"associate_plans\":\"all_plans\",\"billing_cycle\":\"lifetime\",\"billing_period\":\"m\",\"billing_period_num\":1,\"description\":\"\",\"plans_array\":null,\"product_id\":\"5e3a95143c92e44b424b6d47\"}");
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 Add-on:**

- [POST /addon/{{product_id}} — Create Addon](/subscription-billing/add-on/create-addon)
- [GET /addon/{{addonId}} — Get Single Addon](/subscription-billing/add-on/get-single-addon)
- [GET /addons/{{product_id}} — List All Addons](/subscription-billing/add-on/list-all-addons)
- [DELETE /addon/{{addon_id}} — Delete Addon](/subscription-billing/add-on/delete-addon)

