# Remove coupons

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

**Caution** If there are scheduled `[ramps](/docs/api/ramps)` for the subscription, this operation can move the ramps to the [draft](/docs/api/ramps/ramp-object#status) status when it conflicts with any upcoming ramps.

Removes coupons associated with the subscription. If the param `coupon_ids` is not specified, all the coupons linked to the subscription are be removed.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__8asukSOXdxPSQY/remove_coupons \
     -u {site_api_key}:\
     -d "coupon_ids[0]"="P10DISC"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.RemoveCoupons("__test__8asukSOXdxPSQY")
		.CouponIds(new List<string>{"P10DISC"})
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription"
    "github.com/chargebee/chargebee-go/v3/models/subscription"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.RemoveCoupons("__test__8asukSOXdxPSQY", &subscription.RemoveCouponsRequestParams{
        CouponIds : []string{"P10DISC"},
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.SubscriptionRemoveCouponsRequest{
    CouponIds : []string{"P10DISC"},
}
  res, err := client.Subscription.RemoveCoupons("__test__8asukSOXdxPSQY", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.removeCoupons("__test__8asukSOXdxPSQY")
            .couponIds("P10DISC")
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionRemoveCouponsParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionRemoveCouponsResponse;
import java.util.List;

public class SubscriptionRemoveCoupons {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        SubscriptionRemoveCouponsParams params = SubscriptionRemoveCouponsParams.builder()
            .couponIds(List.of("P10DISC"))
            .build();

        SubscriptionRemoveCouponsResponse response = client
            .subscriptions()
            .removeCoupons("__test__8asukSOXdxPSQY", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.subscription.removeCoupons("__test__8asukSOXdxPSQY", {
        coupon_ids: ["P10DISC"]
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->subscription()->removeCoupons("__test__8asukSOXdxPSQY", [
    "coupon_ids" => ["P10DISC"]
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.remove_coupons("__test__8asukSOXdxPSQY",
    cb_client.Subscription.RemoveCouponsParams(
        coupon_ids=["P10DISC"]
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Subscription.remove_coupons("__test__8asukSOXdxPSQY",{
  :coupon_ids => ["P10DISC"]
})

subscription = result.subscription
customer = result.customer
card = result.card
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "off",
    "card_status": "no_card",
    "created_at": 1612890926,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__8asukSOXdxKsQV",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1612890926000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1612890926
  },
  "subscription": {
    "activated_at": 1612890926,
    "billing_period": 1,
    "billing_period_unit": "month",
    "coupon": "A5USD",
    "coupons": [
      {
        "applied_count": 1,
        "apply_till": 1644340526,
        "coupon_id": "A5USD",
        "object": "coupon"
      },
      {..}
    ],
    "created_at": 1612890926,
    "currency_code": "USD",
    "current_term_end": 1615310126,
    "current_term_start": 1612890926,
    "customer_id": "__test__8asukSOXdxKsQV",
    "deleted": false,
    "due_invoices_count": 1,
    "due_since": 1612890926,
    "has_scheduled_changes": false,
    "id": "__test__8asukSOXdxPSQY",
    "mrr": 0,
    "next_billing_at": 1615310126,
    "object": "subscription",
    "remaining_billing_cycles": 1,
    "resource_version": 1612890927000,
    "started_at": 1612890926,
    "status": "active",
    "subscription_items": [
      {
        "amount": 1000,
        "billing_cycles": 1,
        "free_quantity": 0,
        "item_price_id": "basic-USD",
        "item_type": "plan",
        "object": "subscription_item",
        "quantity": 1,
        "unit_price": 1000
      },
      {..}
    ],
    "total_dues": 540,
    "updated_at": 1612890927
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/subscriptions/{subscription-id}/remove_coupons

## Input Parameters

- `coupon_ids` (optional, string, max chars=100)
  List of coupons to be removed from the subscription. You can provide only [coupon\_id](/docs/api/coupons/coupon-object#id) and not [coupon\_code](/docs/api/coupon_codes/coupon_code-object#code) .

## Returns

- `subscription` (Subscription object)
  Resource object representing subscription

- `customer` (Customer object)
  Resource object representing customer

- `card` (Card object)
  Resource object representing card
