# Remove scheduled cancellation

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


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

Removes a scheduled cancellation from a subscription so that it continues billing for the specified number of billing cycles. Use this operation when a customer changes their mind about canceling their subscription.

### Prerequisites & Constraints

-   There must be a cancellation scheduled for the subscription.
-   Do not invoke this API if the subscription has a [`contract_term`](/docs/api/subscriptions#contract_term) associated with it.
-   The subscription must not be a [gift subscription](/docs/api/gifts).
-   The subscription `status` must be `in_trial`, `active` or `non_renewing`.

### Impacts

**

Subscription

**

-   The scheduled cancellation is removed.
-   If the subscription `status` is `in_trial`, it does not change.
-   If the subscription `status` is not `in_trial`, it becomes `active`.
-   [`subscription.remaining_billing_cycles`](/docs/api/subscriptions#remaining_billing_cycles) is set to the value of `billing_cycles`.
-   If `contract_term` is provided, then a new `contract_term` is created on the subscription.

### Implementation Notes

Before calling this API, perform the following checks:

-   Check the `cancelled_at` attribute. It must be set to a future date-time, indicating that a cancellation is scheduled.
-   Ensure that the `contract_term` attribute is not present.
-   Confirm that the subscription `status` is `in_trial`, `active` or `non_renewing`.

#### Related APIs

Cancel a subscription

Pause a subscription

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__8asukSOXdy9TR2/remove_scheduled_cancellation \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.RemoveScheduledCancellation("__test__8asukSOXdy9TR2").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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.RemoveScheduledCancellation("__test__8asukSOXdy9TR2", nil).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.SubscriptionRemoveScheduledCancellationRequest{}
  res, err := client.Subscription.RemoveScheduledCancellation("__test__8asukSOXdy9TR2", 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.removeScheduledCancellation("__test__8asukSOXdy9TR2").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.SubscriptionRemoveScheduledCancellationParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionRemoveScheduledCancellationResponse;

public class SubscriptionRemoveScheduledCancellation {

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

        SubscriptionRemoveScheduledCancellationResponse response = client.subscriptions().removeScheduledCancellation("__test__8asukSOXdy9TR2");

        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.removeScheduledCancellation("__test__8asukSOXdy9TR2");

    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()->removeScheduledCancellation("__test__8asukSOXdy9TR2");
$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_scheduled_cancellation("__test__8asukSOXdy9TR2")
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_scheduled_cancellation("__test__8asukSOXdy9TR2")

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

### Remove scheduled cancellation for a non-renewing subscription.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/6o0O5Uxv3FyNWH/remove_scheduled_cancellation \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.RemoveScheduledCancellation("6o0O5Uxv3FyNWH").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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.RemoveScheduledCancellation("6o0O5Uxv3FyNWH", nil).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.SubscriptionRemoveScheduledCancellationRequest{}
  res, err := client.Subscription.RemoveScheduledCancellation("6o0O5Uxv3FyNWH", 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.removeScheduledCancellation("6o0O5Uxv3FyNWH").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.SubscriptionRemoveScheduledCancellationParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionRemoveScheduledCancellationResponse;

public class SubscriptionRemoveScheduledCancellation {

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

        SubscriptionRemoveScheduledCancellationResponse response = client.subscriptions().removeScheduledCancellation("6o0O5Uxv3FyNWH");

        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.removeScheduledCancellation("6o0O5Uxv3FyNWH");

    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()->removeScheduledCancellation("6o0O5Uxv3FyNWH");
$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_scheduled_cancellation("6o0O5Uxv3FyNWH")
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_scheduled_cancellation("6o0O5Uxv3FyNWH")

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

### Remove a scheduled subscription cancellation and set the number of billing cycles.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/6o0O5Uxv48TCWh/remove_scheduled_cancellation \
     -u {site_api_key}:\
     -d billing_cycles=3
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.RemoveScheduledCancellation("6o0O5Uxv48TCWh")
		.BillingCycles(3)
		.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.RemoveScheduledCancellation("6o0O5Uxv48TCWh", &subscription.RemoveScheduledCancellationRequestParams{
        BillingCycles : chargebee.Int32(3),
    }).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.SubscriptionRemoveScheduledCancellationRequest{
    BillingCycles : chargebee.Int32(3),
}
  res, err := client.Subscription.RemoveScheduledCancellation("6o0O5Uxv48TCWh", 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.removeScheduledCancellation("6o0O5Uxv48TCWh")
            .billingCycles(3)
            .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.SubscriptionRemoveScheduledCancellationParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionRemoveScheduledCancellationResponse;

public class SubscriptionRemoveScheduledCancellation {

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

        SubscriptionRemoveScheduledCancellationParams params = SubscriptionRemoveScheduledCancellationParams.builder()
            .billingCycles(3)
            .build();

        SubscriptionRemoveScheduledCancellationResponse response = client
            .subscriptions()
            .removeScheduledCancellation("6o0O5Uxv48TCWh", 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.removeScheduledCancellation("6o0O5Uxv48TCWh", {
        billing_cycles: 3
    });

    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()->removeScheduledCancellation("6o0O5Uxv48TCWh", [
    "billing_cycles" => 3
]);
$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_scheduled_cancellation("6o0O5Uxv48TCWh",
    cb_client.Subscription.RemoveScheduledCancellationParams(
        billing_cycles=3
    )
)
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_scheduled_cancellation("6o0O5Uxv48TCWh",{
  :billing_cycles => 3
})

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": 1517505329,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__8asukSOXdy5GQz",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505329175,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505329
  },
  "subscription": {
    "activated_at": 1517505329,
    "billing_period": 1,
    "billing_period_unit": "month",
    "created_at": 1517505329,
    "currency_code": "USD",
    "current_term_end": 1519924529,
    "current_term_start": 1517505329,
    "customer_id": "__test__8asukSOXdy5GQz",
    "deleted": false,
    "due_invoices_count": 1,
    "due_since": 1517505329,
    "has_scheduled_changes": false,
    "id": "__test__8asukSOXdy9TR2",
    "mrr": 0,
    "next_billing_at": 1519924529,
    "object": "subscription",
    "resource_version": 1517505330230,
    "started_at": 1517505329,
    "status": "active",
    "subscription_items": [
      {
        "amount": 1000,
        "free_quantity": 0,
        "item_price_id": "basic-USD",
        "item_type": "plan",
        "object": "subscription_item",
        "quantity": 1,
        "unit_price": 1000
      },
      {..}
    ],
    "total_dues": 1100,
    "updated_at": 1517505330
  }
}
```

## URL Format

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

## Input Parameters

- `billing_cycles` (optional, integer, min=0)
  The number of billing cycles the subscription should remain active for after the current billing cycle. The [`remaining_billing_cycles`](/docs/api/subscriptions#remaining_billing_cycles) attribute of the subscription is updated to this value.
  
  **Constraints**
  
  -   The value must be greater than 0.
  
  **Default Value**
  
  -   If not specified, the value set for [`billing_cycles`](/docs/api/item_prices#billing_cycles) on the subscription's plan item price is used.

- `contract_term_billing_cycle_on_renewal` (optional, integer, min=1, max=100)
  Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as `billing_cycles` or a custom value depending on the [site configuration](https://www.chargebee.com/docs/contract-terms.html#configuring-contract-terms) .

- `contract_term` (optional, enumerated string)
  Parameters for contract\_term
  - `action_at_term_end` (optional, enumerated string)
    Action to be taken when the contract term completes.
    Possible enum values:
      - `renew`
        -   Contract term completes and a new contract term is started for the number of billing cycles specified in [`contract_billing_cycle_on_renewal`](/docs/api/v2/pcv-1/subscriptions/create-subscription-for-customer#contract_term_billing_cycle_on_renewal).
        -   The `action_at_term_end` for the new contract term is set to `renew`.
      - `evergreen`
        Contract term completes and the subscription renews.
      - `cancel`
        Contract term completes and subscription is canceled.
  - `cancellation_cutoff_period` (optional, integer, default=0)
    The number of days before [`contract_end`](/docs/api/contract_terms/contract_term-object#contract_end) , during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.

## Returns

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

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

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