# PUT /coupons/{{coupon_id}} — Update Coupon

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

Put request API to update an existing coupon. You can add the coupon Id in request URL. In response the coupon details will be updated for the fields provided. Only the fields included in the request body are modified — this is a partial update, you do not need to send every field. Note: coupon_code, discount, and discount_type are immutable and cannot be modified after a coupon is created. Sending these fields in the request body will return an error.

**Path parameters:**

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

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| coupon_name | string | No | New display name for the coupon |
| valid_upto | string | No | Date until which the coupon is valid. Format: YYYY-MM-DD. Cannot be in the past |
| maximum_redemption | integer | No | Maximum total number of redemptions allowed. Must be greater than zero |
| status | string | No | Activate or deactivate the coupon. Allowed values: active, inactive. When setting to active, the coupon's valid_upto must not be in the past (you can update valid_upto in the same request to reactivate an expired coupon) |
| redemption_type | string | No | How many times the coupon can be redeemed. Allowed values: onetime, forever, number_time |
| redemption_cycle | string | No | Number of redemption cycles. Required when redemption_type is number_time; must be greater than zero |
| associate_plans | string | No | Plan association mode. Allowed values: all_plans, selected_plans |
| plans_array | string | No | Array of plan IDs to associate with the coupon. Required when associate_plans is selected_plans. Automatically cleared when associate_plans is all_plans |
| apply_to | string | No | Where the coupon discount applies. Allowed values: subscription_amount, addon_amount, total_amount |
| apply_affiliate | string | No | Whether to associate this coupon with an affiliate. Allowed values: yes, no |
| affiliate_id | string | No | Affiliate Id. Required when apply_affiliate is yes |

**Example request body:**

```json
{
    "coupon_name": "Diwali Special",
    "valid_upto": "2027-12-31",
    "maximum_redemption": 500,
    "status": "active"
}
```

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

```json
{
    "status": "success",
    "message": "Coupon updated",
    "data": {
        "status": "active",
        "apply_to": "total_amount",
        "createdAt": "2026-03-30T06:00:00.324Z",
        "updatedAt": "2026-03-30T06:00:00.324Z",
        "id": "69ca1160f0ff4d4d40ec4a50",
        "product_id": "69bd317317b5ff7e8de253c7",
        "coupon_name": "Diwali Special",
        "coupon_code": "TEST1",
        "discount": 10,
        "discount_type": "percent",
        "redemption_type": "onetime",
        "redemption_cycle": 0,
        "associate_plans": "all_plans",
        "plans_array": [
            "69ca1187f0ff4d4d40ec4a7c"
        ],
        "valid_upto": "2027-12-31",
        "maximum_redemption": 500,
        "used_redemption": 0
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X PUT https://payments.pabbly.com/api/v1/coupons/{{coupon_id}} \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "coupon_name": "Diwali Special",
    "valid_upto": "2027-12-31",
    "maximum_redemption": 500,
    "status": "active"
  }'
```

_Ruby_

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

uri = URI('https://payments.pabbly.com/api/v1/coupons/{{coupon_id}}')
request = Net::HTTP::Put.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"coupon_name\":\"Diwali Special\",\"valid_upto\":\"2027-12-31\",\"maximum_redemption\":500,\"status\":\"active\"}"

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/coupons/{{coupon_id}}',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'coupon_name': 'Diwali Special',
    'valid_upto': '2027-12-31',
    'maximum_redemption': 500,
    'status': 'active'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/coupons/{{coupon_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, '{"coupon_name":"Diwali Special","valid_upto":"2027-12-31","maximum_redemption":500,"status":"active"}');

$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/coupons/{{coupon_id}}"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString("{\"coupon_name\":\"Diwali Special\",\"valid_upto\":\"2027-12-31\",\"maximum_redemption\":500,\"status\":\"active\"}"));

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/coupons/{{coupon_id}}', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "coupon_name": "Diwali Special",
    "valid_upto": "2027-12-31",
    "maximum_redemption": 500,
    "status": "active"
  }),
});

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

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"coupon_name\":\"Diwali Special\",\"valid_upto\":\"2027-12-31\",\"maximum_redemption\":500,\"status\":\"active\"}")
    req, _ := http.NewRequest("PUT", "https://payments.pabbly.com/api/v1/coupons/{{coupon_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/coupons/{{coupon_id}}");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"coupon_name\":\"Diwali Special\",\"valid_upto\":\"2027-12-31\",\"maximum_redemption\":500,\"status\":\"active\"}");
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 Coupon:**

- [POST /coupon/{{product_id}} — Create Coupon](/subscription-billing/coupon/create-coupon)
- [GET /coupon/{{product_id}} — List All Coupons By Product](/subscription-billing/coupon/list-all-coupons-by-product)
- [DELETE /coupons/{{coupon_id}} — Delete Coupon](/subscription-billing/coupon/delete-coupon)

