# Change billing date

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


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

Applicable when _calendar billing_ (with customer specific billing date support) is enabled. Changes the customer's _billing\_date_ and/or _billing\_day\_of\_week_.

During this operation the upcoming renewal dates are **not** updated to align immediately with the new date. The alignment will happen during subsequent renewals. For example, a customer's upcoming renewal is scheduled for _January 10th_, when the customer's billing date is changed to the _15th_, the next renewal date is still _January 10th_. The new billing date does not take effect until the subsequent renewal, which in this case is _February 15th_. If you want to align with the new date immediately (in this example: you want the next renewal to be on _January 15th_ and not _January 10th_) you need to manually [change the subscription's term end](/docs/api/subscriptions/change-term-end).

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWl5XP2b6/change_billing_date \
     -u {site_api_key}:\
     -d billing_date=15 \
     -d billing_date_mode="MANUALLY_SET" \
     -d billing_day_of_week="SUNDAY" \
     -d billing_day_of_week_mode="MANUALLY_SET"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.ChangeBillingDate("__test__KyVnHhSBWl5XP2b6")
		.BillingDate(15)
		.BillingDateMode(BillingDateModeEnum.ManuallySet)
		.BillingDayOfWeek(Customer.BillingDayOfWeekEnum.Sunday)
		.BillingDayOfWeekMode(BillingDayOfWeekModeEnum.ManuallySet)
		.Request();

Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
    enum "github.com/chargebee/chargebee-go/v3/enum"
    customerEnum "github.com/chargebee/chargebee-go/v3/models/customer/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.ChangeBillingDate("__test__KyVnHhSBWl5XP2b6", &customer.ChangeBillingDateRequestParams{
        BillingDate : chargebee.Int32(15),
        BillingDateMode : enum.BillingDateModeManuallySet,
        BillingDayOfWeek : customerEnum.BillingDayOfWeekSunday,
        BillingDayOfWeekMode : enum.BillingDayOfWeekModeManuallySet,
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### 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.CustomerChangeBillingDateRequest{
    BillingDate : chargebee.Int32(15),
    BillingDateMode : chargebee.BillingDateModeManuallySet,
    BillingDayOfWeek : chargebee.CustomerBillingDayOfWeekSunday,
    BillingDayOfWeekMode : chargebee.BillingDayOfWeekModeManuallySet,
}
  res, err := client.Customer.ChangeBillingDate("__test__KyVnHhSBWl5XP2b6", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### 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 = Customer.changeBillingDate("__test__KyVnHhSBWl5XP2b6")
            .billingDate(15)
            .billingDateMode(BillingDateMode.MANUALLY_SET)
            .billingDayOfWeek(Customer.BillingDayOfWeek.SUNDAY)
            .billingDayOfWeekMode(BillingDayOfWeekMode.MANUALLY_SET)
            .request();

        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerChangeBillingDateParams;
import com.chargebee.v4.models.customer.responses.CustomerChangeBillingDateResponse;

public class CustomerChangeBillingDate {

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

        CustomerChangeBillingDateParams params = CustomerChangeBillingDateParams.builder()
            .billingDate(15)
            .billingDateMode(CustomerChangeBillingDateParams.BillingDateMode.MANUALLY_SET)
            .billingDayOfWeek(CustomerChangeBillingDateParams.BillingDayOfWeek.SUNDAY)
            .billingDayOfWeekMode(CustomerChangeBillingDateParams.BillingDayOfWeekMode.MANUALLY_SET)
            .build();

        CustomerChangeBillingDateResponse response = client
            .customers()
            .changeBillingDate("__test__KyVnHhSBWl5XP2b6", params);

        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.customer.changeBillingDate("__test__KyVnHhSBWl5XP2b6", {
        billing_date: 15,
        billing_date_mode: "manually_set",
        billing_day_of_week: "sunday",
        billing_day_of_week_mode: "manually_set"
    });

    console.log(result);
    const customer = result.customer;
} 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->customer()->changeBillingDate("__test__KyVnHhSBWl5XP2b6", [
    "billing_date" => 15,
    "billing_date_mode" => "manually_set",
    "billing_day_of_week" => "sunday",
    "billing_day_of_week_mode" => "manually_set"
]);
$customer = $result->customer;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.change_billing_date("__test__KyVnHhSBWl5XP2b6",
    cb_client.Customer.ChangeBillingDateParams(
        billing_date=15,
        billing_date_mode=chargebee.BillingDateMode.MANUALLY_SET,
        billing_day_of_week=chargebee.Customer.BillingDayOfWeek.SUNDAY,
        billing_day_of_week_mode=chargebee.BillingDayOfWeekMode.MANUALLY_SET
    )
)
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Customer.change_billing_date("__test__KyVnHhSBWl5XP2b6",{
  :billing_date => 15,
  :billing_date_mode => "MANUALLY_SET",
  :billing_day_of_week => "SUNDAY",
  :billing_day_of_week_mode => "MANUALLY_SET"
})

customer = result.customer
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "on",
    "billing_date": 15,
    "billing_date_mode": "manually_set",
    "billing_day_of_week": "sunday",
    "billing_day_of_week_mode": "manually_set",
    "card_status": "no_card",
    "created_at": 1517505722,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__KyVnHhSBWl5XP2b6",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505723000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505723
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/customers/{customer-id}/change_billing_date

## Input Parameters

- `billing_date` (optional, integer, min=1, max=31)
  Applicable when _calendar billing_ (with customer specific billing date support) is enabled. When set, renewals of all the monthly and yearly subscriptions of this customer will be aligned to this date.

- `billing_month` (optional, integer, min=1, max=12)
  `billing_month`, together with `billing_date`, specify, for this customer, the day of the year when the renewals of all the year-based subscriptions take place.
  
  For example, the renewals happen on 15th July when `billing_month` is `7` and `billing_date` is `15`.
  
  **Note** Applicable when [Calendar Billing](https://www.chargebee.com/docs/calendar-billing.html) (with customer-specific billing date support) is enabled and `billing_date_mode` is `manually_set`.

- `billing_date_mode` (optional, enumerated string)
  Indicates whether this customer's _billing\_date_ value is derived as per configurations or its specifically set (overriden). When specifically set, the _billing\_date_ will not be reset even when all of the monthly/yearly subscriptions are cancelled.
  Possible enum values:
    - `using_defaults`
      Billing date is set based on defaults configured.
    - `manually_set`
      Billing date is specifically set (default configuration is overridden)

- `billing_day_of_week` (optional, enumerated string)
  Applicable when _calendar billing_ (with customer specific billing date support) is enabled. When set, renewals of all the weekly subscriptions of this customer will be aligned to this week day.
  Possible enum values:
    - `sunday`
      Sunday
    - `monday`
      Monday
    - `tuesday`
      Tuesday
    - `wednesday`
      Wednesday
    - `thursday`
      Thursday
    - `friday`
      Friday
    - `saturday`
      Saturday

- `billing_day_of_week_mode` (optional, enumerated string)
  Indicates whether this customer's _billing\_day\_of\_week_ value is derived as per configurations or its specifically set (overriden). When specifically set, the _billing\_day\_of\_week_ will not be reset even when all of the weekly subscriptions are cancelled.
  Possible enum values:
    - `using_defaults`
      Billing date is set based on defaults configured.
    - `manually_set`
      Billing date is specifically set (default configuration is overridden)

## Returns

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