# PUT /subscription/custom-fields/{{subscription_id}} — Update Custom Fields to Subscription

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

This API can be used to add custom fields in a particular subscription. It will be fired with PUT request. subscription_id will be added in Request URL. In response you will get Success status and the plan checkout page will be updated with the custom fields.

**Path parameters:**

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

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| custom_fields | object | Yes | Phone number and additional_magazines in the form data are custom fields. You can add fields according to your needs. |
|   ↳ gst_number | string | No |  |
|   ↳ pan_number | string | No |  |

**Example request body:**

```json
{
   "custom_fields": {
        "gst_number": "GST45788555",
        "pan_number": "PAN785554"
    }
}
```

**Response (200)** — Update Custom Fields With Subscription:

```json
{
    "status": "success",
    "message": "Custom fields updated successfully",
    "data": {
        "plan": {
            "plan_type": "per_unit",
            "plan_active": "true",
            "meta_data": {
                "tasks": "50000",
                "workflows": "1000"
            },
            "failed_payment_gateway_array": [],
            "failed_payment_gateway": "all",
            "setup_fee_type": "",
            "trial_type": "day",
            "funnel": [],
            "currency_code": "USD",
            "currency_symbol": "$",
            "custom_payment_term": 0,
            "is_metered": false,
            "createdAt": "2022-06-10T14:26:58.876Z",
            "updatedAt": "2023-09-12T11:29:11.002Z",
            "id": "62a354b2ffddb0508a05ed91",
            "product_id": "61a21b098c4b5732e5a3437d",
            "plan_name": "Test Plan",
            "plan_code": "updated_plan",
            "price": 100,
            "billing_period": "m",
            "billing_period_num": "1",
            "billing_cycle": "lifetime",
            "billing_cycle_num": "",
            "trial_period": 0,
            "setup_fee": 0,
            "plan_description": "Dummy plan"
        },
        "setup_fee": 0,
        "currency_code": "USD",
        "currency_symbol": "$",
        "payment_method": "6516ac0ff42a304a1b2e0175",
        "taxable": true,
        "gateway_type": "test",
        "payment_terms": "net0",
        "gateway_id": "608bb918996ba815ec7ac5b5",
        "gateway_name": "Testing Gateway",
        "custom_fields": [
            {
                "name": "gst_number",
                "type": "text",
                "label": "GST Number",
                "value": "GST45788555"
            },
            {
                "name": "pan_number",
                "type": "text",
                "label": "PAN Number",
                "value": "PAN785554"
            }
        ],
        "requested_ip": "2401:4900:1ca2:31d7:1516:941f:ec58:e755",
        "createdAt": "2023-09-29T10:50:54.747Z",
        "updatedAt": "2023-09-29T12:12:00.054Z",
        "id": "6516ac0ef42a304a1b2e0172",
        "customer_id": "6516ac0ef42a304a1b2e0170",
        "product_id": "61a21b098c4b5732e5a3437d",
        "plan_id": "62a354b2ffddb0508a05ed91",
        "amount": 100,
        "email_id": "notice-characteristic-46@inboxkitten.com",
        "status": "live",
        "quantity": 1,
        "starts_at": "2023-09-29T10:50:54.545Z",
        "activation_date": "2023-09-29T10:50:55.555Z",
        "expiry_date": "2123-09-29T10:50:54.545Z",
        "trial_days": 0,
        "trial_expiry_date": "",
        "next_billing_date": "2023-10-29T10:50:55.555Z",
        "last_billing_date": "2023-09-29T10:50:55.555Z",
        "canceled_date": null
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X PUT https://payments.pabbly.com/api/v1/subscription/custom-fields/{{subscription_id}} \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "custom_fields": {
      "gst_number": "GST45788555",
      "pan_number": "PAN785554"
    }
  }'
```

_Ruby_

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

uri = URI('https://payments.pabbly.com/api/v1/subscription/custom-fields/{{subscription_id}}')
request = Net::HTTP::Put.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"custom_fields\":{\"gst_number\":\"GST45788555\",\"pan_number\":\"PAN785554\"}}"

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/custom-fields/{{subscription_id}}',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'custom_fields': {
        'gst_number': 'GST45788555',
        'pan_number': 'PAN785554'
    }
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/subscription/custom-fields/{{subscription_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, '{"custom_fields":{"gst_number":"GST45788555","pan_number":"PAN785554"}}');

$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/custom-fields/{{subscription_id}}"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString("{\"custom_fields\":{\"gst_number\":\"GST45788555\",\"pan_number\":\"PAN785554\"}}"));

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/custom-fields/{{subscription_id}}', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "custom_fields": {
      "gst_number": "GST45788555",
      "pan_number": "PAN785554"
    }
  }),
});

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

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"custom_fields\":{\"gst_number\":\"GST45788555\",\"pan_number\":\"PAN785554\"}}")
    req, _ := http.NewRequest("PUT", "https://payments.pabbly.com/api/v1/subscription/custom-fields/{{subscription_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/subscription/custom-fields/{{subscription_id}}");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"custom_fields\":{\"gst_number\":\"GST45788555\",\"pan_number\":\"PAN785554\"}}");
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 Custom Field:**

- [GET /api/v1/customfields/{{plan_id}} — Get Custom Fields](/subscription-billing/custom-field/get-custom-fields)

