# Subscription renewal estimate

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


This returns an estimate of the amount that will be charged when the subscription is billed next. The estimate is calculated based on the current recurring items of the subscription - plan, addons, and coupons.

In the response,

-   **estimate.subscription\_estimate** has the current subscription details like its status, next billing date, and so on.

**estimate.invoice\_estimate** has details of the invoice that will be generated at the next billing date.

The generated invoice estimate will include all the balances - [Promotional Credits](https://www.chargebee.com/docs/promotional-credits.html) , Refundable Credits, and Excess Payments - if any. If you don't want these balances to be included you can specify 'false' for the parameter _use\_existing\_balances_ .

To exclude the [delayed charges](https://www.chargebee.com/docs/charges.html) from the invoice estimate, specify 'false' for the parameter _include\_delayed\_charges_ .

**Note:**

-   This API will not generate a renewal invoice if an [advance invoice](https://www.chargebee.com/docs/advance-invoices.html) is already present for the subscription.
-   For 'Non Renewing' subscriptions, only the [delayed charges](https://www.chargebee.com/docs/charges.html) will be included in the invoice estimate.
-   This API is not supported for 'Cancelled' subscriptions.
-   Only the subscription's charges will be included. If you have enabled the Consolidated invoicing feature, use the _Upcoming Invoices_ estimate available for the Customer object to get the actual estimate invoice for the customer.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__8asyKSOceZXgNK/renewal_estimate \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.RenewalEstimate("__test__8asyKSOceZXgNK").Request();

Estimate estimate = result.Estimate;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    estimateAction "github.com/chargebee/chargebee-go/v3/actions/estimate"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := estimateAction.RenewalEstimate("__test__8asyKSOceZXgNK", nil).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Estimate := res.Estimate
    }
}
```

#### 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.EstimateRenewalEstimateRequest{}
  res, err := client.Estimate.RenewalEstimate("__test__8asyKSOceZXgNK", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Estimate := res.Estimate
    }
}
```

#### 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 = Estimate.renewalEstimate("__test__8asyKSOceZXgNK").request();

        Estimate estimate = result.estimate();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.estimate.Estimate;
import com.chargebee.v4.models.estimate.params.RenewalEstimateParams;
import com.chargebee.v4.models.estimate.responses.RenewalEstimateResponse;

public class RenewalEstimate {

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

        RenewalEstimateResponse response = client.estimates().renewalEstimate("__test__8asyKSOceZXgNK");

        Estimate estimate = response.getEstimate();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.estimate.renewalEstimate("__test__8asyKSOceZXgNK");

    console.log(result);
    const estimate = result.estimate;
} 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->estimate()->renewalEstimate("__test__8asyKSOceZXgNK");
$estimate = $result->estimate;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Estimate.renewal_estimate("__test__8asyKSOceZXgNK")
estimate = response.estimate
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Estimate.renewal_estimate("__test__8asyKSOceZXgNK")

estimate = result.estimate
```

## Sample Response

```json
{
  "estimate": {
    "created_at": 1517492955,
    "invoice_estimate": {
      "amount_due": 1000,
      "amount_paid": 0,
      "credits_applied": 0,
      "currency_code": "USD",
      "customer_id": "__test__8asyKSOceZS2ND",
      "line_item_discounts": {},
      "line_item_taxes": {},
      "line_items": [
        {
          "amount": 1000,
          "customer_id": "__test__8asyKSOceZS2ND",
          "date_from": 1519912154,
          "date_to": 1522590554,
          "description": "basic USD",
          "discount_amount": 0,
          "entity_id": "basic-USD",
          "entity_type": "plan_item_price",
          "id": "li___test__8asyKSOceZjINU",
          "is_taxed": false,
          "item_level_discount_amount": 0,
          "object": "line_item",
          "pricing_model": "per_unit",
          "quantity": 1,
          "subscription_id": "__test__8asyKSOceZXgNK",
          "tax_amount": 0,
          "unit_amount": 1000
        },
        {..}
      ],
      "object": "invoice_estimate",
      "price_type": "tax_exclusive",
      "recurring": true,
      "round_off_amount": 0,
      "sub_total": 1000,
      "taxes": {},
      "total": 1000
    },
    "object": "estimate",
    "subscription_estimate": {
      "currency_code": "USD",
      "id": "__test__8asyKSOceZXgNK",
      "next_billing_at": 1519912154,
      "object": "subscription_estimate",
      "status": "active"
    }
  }
}
```

## URL Format

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

## Input Parameters

- `include_delayed_charges` (optional, boolean, default=true)
  If true, all the unbilled charges will be included for the invoice estimate.

- `use_existing_balances` (optional, boolean, default=true)
  The generated invoice\_estimate/next\_invoice\_estimate will include all the balances - Promotional Credits, Refundable Credits, and Excess Payments - if any. If you don't want these balances to be included you can specify 'false' for the parameter `use_existing_balances`.

- `ignore_scheduled_cancellation` (optional, boolean, default=false)
  if true, ignores scheduled cancellation for non renewing subscription.

- `ignore_scheduled_changes` (optional, boolean, default=false)
  If true, ignores all recurring charges scheduled during renewal.

- `exclude_tax_type` (optional, enumerated string, default=none)
  Indicates whether tax calculation should be excluded for the operation. This attribute is applicable only when a third-party tax provider is configured. If no such provider is set up, this parameter will be ignored.
  Possible enum values:
    - `exclusive`
    - `none`

## Returns

- `estimate` (Estimate object)
  Resource object representing estimate
