# Pause a subscription

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


[Idempotency Supported](/docs/api/v2/pcv-1/idempotency)

Pauses the subscription, changing its `status` to `paused`. This prevents the subscription from getting renewed. No new charges are created until the subscription is resumed.

#### Note:[](#note)

-   Applicable only for **active/non-renewing** subscriptions.
-   If paused indefinitely, the subscription is cancelled on the `[cancelled_at](/docs/api/subscriptions/subscription-object#cancelled_at)` date.
-   Advance charges, if any, are refunded as credits.

## Sample Request

### pauses the subscription on end of term.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__KyVnHhSBWkqkc2WM/pause \
     -u {site_api_key}:\
     -d pause_option="END_OF_TERM"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Pause("__test__KyVnHhSBWkqkc2WM")
		.PauseOption(PauseOptionEnum.EndOfTerm)
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
Invoice invoice = result.Invoice;
List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
List<CreditNote> creditNotes = result.CreditNotes;
```

#### 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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Pause("__test__KyVnHhSBWkqkc2WM", &subscription.PauseRequestParams{
        PauseOption : enum.PauseOptionEndOfTerm,
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
        CreditNotes := res.CreditNotes
    }
}
```

#### 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.SubscriptionPauseRequest{
    PauseOption : chargebee.PauseOptionEndOfTerm,
}
  res, err := client.Subscription.Pause("__test__KyVnHhSBWkqkc2WM", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
        CreditNotes := res.CreditNotes
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.pause("__test__KyVnHhSBWkqkc2WM")
            .pauseOption(PauseOption.END_OF_TERM)
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
        Invoice invoice = result.invoice();
        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        List<CreditNote> creditNotes = result.creditNotes();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.creditNote.CreditNote;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionPauseParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionPauseResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionPause {

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

        SubscriptionPauseParams params = SubscriptionPauseParams.builder()
            .pauseOption(SubscriptionPauseParams.PauseOption.END_OF_TERM)
            .build();

        SubscriptionPauseResponse response = client
            .subscriptions()
            .pause("__test__KyVnHhSBWkqkc2WM", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
        Invoice invoice = response.getInvoice();
        List<UnbilledCharge> unbilledCharges = response.getUnbilledCharges();
        List<CreditNote> creditNotes = response.getCreditNotes();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.subscription.pause("__test__KyVnHhSBWkqkc2WM", {
        pause_option: "end_of_term"
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
    const invoice = result.invoice;
    const unbilledCharges = result.unbilled_charges;
    const creditNotes = result.credit_notes;
} 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()->pause("__test__KyVnHhSBWkqkc2WM", [
    "pause_option" => "end_of_term"
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
$creditNotes = $result->credit_notes;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.pause("__test__KyVnHhSBWkqkc2WM",
    cb_client.Subscription.PauseParams(
        pause_option=chargebee.PauseOption.END_OF_TERM
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
invoice = response.invoice
unbilled_charges = response.unbilled_charges
credit_notes = response.credit_notes
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Subscription.pause("__test__KyVnHhSBWkqkc2WM",{
  :pause_option => "END_OF_TERM"
})

subscription = result.subscription
customer = result.customer
card = result.card
invoice = result.invoice
unbilled_charges = result.unbilled_charges
credit_notes = result.credit_notes
```

### pauses the subscription immediately .Invoice will be raised for the unbilledcharges present.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__KyVnHhSBWkr7v2WU/pause \
     -u {site_api_key}:\
     -d pause_option="IMMEDIATELY" \
     -d unbilled_charges_handling="INVOICE"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Pause("__test__KyVnHhSBWkr7v2WU")
		.PauseOption(PauseOptionEnum.Immediately)
		.UnbilledChargesHandling(UnbilledChargesHandlingEnum.Invoice)
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
Invoice invoice = result.Invoice;
List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
List<CreditNote> creditNotes = result.CreditNotes;
```

#### 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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Pause("__test__KyVnHhSBWkr7v2WU", &subscription.PauseRequestParams{
        PauseOption : enum.PauseOptionImmediately,
        UnbilledChargesHandling : enum.UnbilledChargesHandlingInvoice,
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
        CreditNotes := res.CreditNotes
    }
}
```

#### 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.SubscriptionPauseRequest{
    PauseOption : chargebee.PauseOptionImmediately,
    UnbilledChargesHandling : chargebee.UnbilledChargesHandlingInvoice,
}
  res, err := client.Subscription.Pause("__test__KyVnHhSBWkr7v2WU", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
        CreditNotes := res.CreditNotes
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.pause("__test__KyVnHhSBWkr7v2WU")
            .pauseOption(PauseOption.IMMEDIATELY)
            .unbilledChargesHandling(UnbilledChargesHandling.INVOICE)
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
        Invoice invoice = result.invoice();
        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        List<CreditNote> creditNotes = result.creditNotes();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.creditNote.CreditNote;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionPauseParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionPauseResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionPause {

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

        SubscriptionPauseParams params = SubscriptionPauseParams.builder()
            .pauseOption(SubscriptionPauseParams.PauseOption.IMMEDIATELY)
            .unbilledChargesHandling(SubscriptionPauseParams.UnbilledChargesHandling.INVOICE)
            .build();

        SubscriptionPauseResponse response = client
            .subscriptions()
            .pause("__test__KyVnHhSBWkr7v2WU", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
        Invoice invoice = response.getInvoice();
        List<UnbilledCharge> unbilledCharges = response.getUnbilledCharges();
        List<CreditNote> creditNotes = response.getCreditNotes();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.subscription.pause("__test__KyVnHhSBWkr7v2WU", {
        pause_option: "immediately",
        unbilled_charges_handling: "invoice"
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
    const invoice = result.invoice;
    const unbilledCharges = result.unbilled_charges;
    const creditNotes = result.credit_notes;
} 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()->pause("__test__KyVnHhSBWkr7v2WU", [
    "pause_option" => "immediately",
    "unbilled_charges_handling" => "invoice"
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
$creditNotes = $result->credit_notes;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.pause("__test__KyVnHhSBWkr7v2WU",
    cb_client.Subscription.PauseParams(
        pause_option=chargebee.PauseOption.IMMEDIATELY,
        unbilled_charges_handling=chargebee.UnbilledChargesHandling.INVOICE
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
invoice = response.invoice
unbilled_charges = response.unbilled_charges
credit_notes = response.credit_notes
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Subscription.pause("__test__KyVnHhSBWkr7v2WU",{
  :pause_option => "IMMEDIATELY",
  :unbilled_charges_handling => "INVOICE"
})

subscription = result.subscription
customer = result.customer
card = result.card
invoice = result.invoice
unbilled_charges = result.unbilled_charges
credit_notes = result.credit_notes
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "off",
    "card_status": "no_card",
    "created_at": 1517505666,
    "deleted": false,
    "excess_payments": 0,
    "id": "__test__KyVnHhSBWkqkc2WM",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505666000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505666
  },
  "subscription": {
    "activated_at": 1517505666,
    "billing_period": 1,
    "billing_period_unit": "month",
    "created_at": 1517505666,
    "currency_code": "USD",
    "current_term_end": 1519924866,
    "current_term_start": 1517505666,
    "customer_id": "__test__KyVnHhSBWkqkc2WM",
    "deleted": false,
    "due_invoices_count": 1,
    "due_since": 1517505666,
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWkqkc2WM",
    "mrr": 0,
    "object": "subscription",
    "pause_date": 1519924866,
    "plan_amount": 895,
    "plan_free_quantity": 0,
    "plan_id": "no_trial",
    "plan_quantity": 1,
    "plan_unit_price": 895,
    "resource_version": 1517505666000,
    "started_at": 1517505666,
    "status": "active",
    "total_dues": 895,
    "updated_at": 1517505666
  }
}
```

## URL Format

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

## Input Parameters

- `pause_option` (optional, enumerated string)
  List of options to pause the subscription.
  Possible enum values:
    - `immediately`
      Pause immediately
    - `end_of_term`
      Pause at the end of current term
    - `specific_date`
      Pause on a specific date
    - `billing_cycles`
      Pause at the end of the current term, and resume automatically after the set number of billing cycles (in `[skip_billing_cycles](/docs/api/subscriptions/pause-a-subscription#skip_billing_cycles)`) have been skipped

- `pause_date` (optional, timestamp(UTC) in seconds)
  Date on which the subscription will be paused. Applicable when `specific_date` option is chosen in the `[pause_option](/docs/api/subscriptions/pause-a-subscription#pause_option)` field. For non-renewing subscriptions, `pause_date` should be before the cancellation date.

- `unbilled_charges_handling` (optional, enumerated string)
  Applicable when unbilled charges are present for the subscription and `[pause_option](/docs/api/subscriptions/pause-a-subscription#pause_option)` is set as `immediately`. **Note:** On the invoice raised, an automatic charge is attempted on the payment method available, if customer's auto-collection property is set to `on`.
  Possible enum values:
    - `no_action`
      Retain as unbilled If `no_action` is chosen, charges are added to the resumption invoice.
    - `invoice`
      Invoice charges If `invoice` is chosen, an automatic charge is attempted on the payment method available if the customer has enabled auto-collection. If a payment collection fails or when auto-collection is not enabled, the invoice is closed as unpaid.

- `invoice_dunning_handling` (optional, enumerated string)
  Handles dunning for invoices already in the dunning cycle when a subscription is paused. Applicable when `[pause_option](/docs/api/subscriptions/pause-a-subscription#pause_option)` is set as `immediately`. If invoice is in the dunning cycle, `invoice_dunning_handing` allows you to `stop` or `continue` dunning.
  Possible enum values:
    - `continue`
      Continue dunning
    - `stop`
      Stop dunning

- `skip_billing_cycles` (optional, integer, min=1)
  The number of subscription billing cycles that will be skipped. The subscription resumes after the set number of billing cycles have been skipped. This is applicable only when the value of of `[pause_option](/docs/api/subscriptions/pause-a-subscription#pause_option)` is `billing_cycles` .

- `resume_date` (optional, timestamp(UTC) in seconds)
  For a paused subscription, it is the date/time when the subscription is scheduled to resume. If the pause is for an indefinite period, this value is not returned. For non-renewing subscriptions,`resume_date` should be before the cancellation date.

## Returns

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

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

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

- `invoice` (Invoice object)
  Resource object representing invoice

- `unbilled_charges` (optional)
  Resource object representing unbilled\_charge

- `credit_notes` (optional)
  Resource object representing credit\_note
