# Create a payment schedule estimate

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


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

Generates an estimate without creating a payment schedule. This endpoint can be called when you want to preview details of a new payment schedule before actually creating one.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/estimates/payment_schedules \
     -u {site_api_key}:\
     -d scheme_id="scheme1" \
     -d invoice_id="cbdemo_inv_003" \
     -d amount=100000 \
     -d payment_schedule_start_date=1707302531
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.PaymentSchedules()
		.SchemeId("scheme1")
		.InvoiceId("cbdemo_inv_003")
		.Amount(100000)
		.PaymentScheduleStartDate(1707302531)
		.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"
    "github.com/chargebee/chargebee-go/v3/models/estimate"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := estimateAction.PaymentSchedules(&estimate.PaymentSchedulesRequestParams{
        SchemeId : "scheme1",
        InvoiceId : "cbdemo_inv_003",
        Amount : chargebee.Int64(100000),
        PaymentScheduleStartDate : chargebee.Int64(1707302531),
    }).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.EstimatePaymentSchedulesRequest{
    SchemeId : "scheme1",
    InvoiceId : "cbdemo_inv_003",
    Amount : chargebee.Int64(100000),
    PaymentScheduleStartDate : chargebee.Int64(1707302531),
}
  res, err := client.Estimate.PaymentSchedules(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;
import java.sql.Timestamp;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Estimate.paymentSchedules()
            .schemeId("scheme1")
            .invoiceId("cbdemo_inv_003")
            .amount(100000L)
            .paymentScheduleStartDate(new Timestamp(1707302531L * 1000))
            .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.EstimatePaymentSchedulesParams;
import com.chargebee.v4.models.estimate.responses.EstimatePaymentSchedulesResponse;
import java.sql.Timestamp;

public class EstimatePaymentSchedules {

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

        EstimatePaymentSchedulesParams params = EstimatePaymentSchedulesParams.builder()
            .schemeId("scheme1")
            .invoiceId("cbdemo_inv_003")
            .amount(100000L)
            .paymentScheduleStartDate(new Timestamp(1707302531L * 1000))
            .build();

        EstimatePaymentSchedulesResponse response = client.estimates().paymentSchedules(params);

        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.paymentSchedules({
        scheme_id: "scheme1",
        invoice_id: "cbdemo_inv_003",
        amount: 100000,
        payment_schedule_start_date: 1707302531
    });

    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()->paymentSchedules([
    "scheme_id" => "scheme1",
    "invoice_id" => "cbdemo_inv_003",
    "amount" => 100000,
    "payment_schedule_start_date" => 1707302531
]);
$estimate = $result->estimate;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Estimate.payment_schedules(
    cb_client.Estimate.PaymentSchedulesParams(
        scheme_id="scheme1",
        invoice_id="cbdemo_inv_003",
        amount=100000,
        payment_schedule_start_date=1707302531
    )
)
estimate = response.estimate
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Estimate.payment_schedules({
  :scheme_id => "scheme1",
  :invoice_id => "cbdemo_inv_003",
  :amount => 100000,
  :payment_schedule_start_date => 1707302531
})

estimate = result.estimate
```

## Sample Response

```json
{
  "estimate": {
    "created_at": 1707302531,
    "payment_schedule_estimates": [
      {
        "id": "__dev__Hw7wpIzUKlI7yLl",
        "entity_type": "invoice",
        "entity_id": "cbdemo_inv_003",
        "scheme_id": "scheme1",
        "currency_code": "USD",
        "object": "payment_schedule_estimate",
        "schedule_entries": [
          {
            "id": "__dev__Hw7wpIzUKlI7yWm",
            "date": 1707302531,
            "amount": 33333,
            "status": "posted",
            "object": "schedule_entry"
          },
          {..}
        ]
      },
      {..}
    ]
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/estimates/payment_schedules

## Input Parameters

- `scheme_id` (required, string)
  The unique identifier for the `payment_schedule_scheme`. This identifier is used to retrieve the payment schedule scheme, which is then applied to calculate the amount and date for the specified number of payment schedules.

- `amount` (optional, in cents, min=0)
  Defines the payment schedule amount set for an invoice. If this is not provided, the total `invoice.amount_due` is used. This value is mandatory in case `invoice_id` is not provided.

- `invoice_id` (optional, string)
  Unique identifier of the invoice.

- `payment_schedule_start_date` (optional, timestamp(UTC) in seconds)
  The date from which the payment schedule will start. This is applicable only when invoice\_id is not provided. If `invoice_id` is provided, we will consider `invoice.due_date` .

## Returns

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