# Update the overdraft limit

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


Updates the [overdraft limit](/docs/api/ledger_account_balances#overdraft_balance_limit) for a subscription and credit unit.

By default, the overdraft limit for a credit unit is a single, site-wide value applied to every subscription. Use this operation to manually override that default for one `subscription_id`\-`unit_id` pair — for example, to raise the ceiling for a trusted high-value customer, or to let customers self-configure their own spending limit after credits are granted.

**Behavior**

-   Applies the new limit synchronously and returns the outcome in the same response — there's no pending or asynchronous state.
-   Rejects the request immediately if the new limit is below what's already committed (`used_amount` + `hold_amount`) on the active overdraft balance. The limit isn't scheduled or retried later; the caller must resubmit once the balance permits it.
-   Requires that an overdraft balance already exists for the subscription and credit unit.
-   Leaves the [`provisioned_balance`](/docs/api/ledger_account_balances#provisioned_balance) and the site-level default untouched. Other subscriptions on the same credit unit continue to use the site default until they get their own override.

**Usage**

Use this operation to raise or lower the overdraft ceiling for a specific subscription without changing the site-wide default — for instance, extending more runway to an enterprise customer, or letting an end customer raise their own limit after receiving promotional credits.

The response echoes the `subscription_id`, `unit_id`, and `change_reason` inputs, and returns the resulting [`overdraft_balance`](/docs/api/ledger_account_balances#overdraft_balance) snapshot as well.

## Sample Request

#### Chargebee CLI

```bash
chargebee ledger-account-balance update-overdraft-limit \
    -d subscription_id=Azq7EgV4oPCVI7Iw \
    -d unit_id=ai_credits \
    -d is_unlimited=false \
    -d limit=250 \
    -d 'change_reason=Customer-approved limit change'
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/ledger_account_balances/update_overdraft_limit \
     -u {site_api_key}:\
     -d subscription_id="Azq7EgV4oPCVI7Iw" \
     -d unit_id="ai_credits" \
     -d is_unlimited="false" \
     -d limit="250" \
     -d change_reason="Customer-approved limit change"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = LedgerAccountBalance.UpdateOverdraftLimit()
		.SubscriptionId("Azq7EgV4oPCVI7Iw")
		.UnitId("ai_credits")
		.IsUnlimited(false)
		.Limit("250")
		.ChangeReason("Customer-approved limit change")
		.Request();
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    ledgeraccountbalanceAction "github.com/chargebee/chargebee-go/v3/actions/ledgeraccountbalance"
    "github.com/chargebee/chargebee-go/v3/models/ledgeraccountbalance"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := ledgeraccountbalanceAction.UpdateOverdraftLimit(&ledgeraccountbalance.UpdateOverdraftLimitRequestParams{
        SubscriptionId : "Azq7EgV4oPCVI7Iw",
        UnitId : "ai_credits",
        IsUnlimited : chargebee.Bool(false),
        Limit : "250",
        ChangeReason : "Customer-approved limit change",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(res)
    }
}
```

#### 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.LedgerAccountBalanceUpdateOverdraftLimitRequest{
    SubscriptionId : "Azq7EgV4oPCVI7Iw",
    UnitId : "ai_credits",
    IsUnlimited : chargebee.Bool(false),
    Limit : "250",
    ChangeReason : "Customer-approved limit change",
}
  res, err := client.LedgerAccountBalance.UpdateOverdraftLimit(req)
      if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(res)
    }
}
```

#### 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 = LedgerAccountBalance.updateOverdraftLimit()
            .subscriptionId("Azq7EgV4oPCVI7Iw")
            .unitId("ai_credits")
            .isUnlimited(false)
            .changeReason("Customer-approved limit change")
            .param("limit", "250")
            .request();

        LedgerAccountBalance ledgerAccountBalance = result.ledgerAccountBalance();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.ledgerAccountBalance.params.LedgerAccountBalanceUpdateOverdraftLimitParams;
import com.chargebee.v4.models.ledgerAccountBalance.responses.LedgerAccountBalanceUpdateOverdraftLimitResponse;

public class LedgerAccountBalanceUpdateOverdraftLimit {

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

        LedgerAccountBalanceUpdateOverdraftLimitParams params = LedgerAccountBalanceUpdateOverdraftLimitParams.builder()
            .subscriptionId("Azq7EgV4oPCVI7Iw")
            .unitId("ai_credits")
            .isUnlimited(false)
            .limit("250")
            .changeReason("Customer-approved limit change")
            .build();

        LedgerAccountBalanceUpdateOverdraftLimitResponse response = client.ledgerAccountBalances().updateOverdraftLimit(params);

        System.out.println(response);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.ledgerAccountBalance.updateOverdraftLimit({
        subscription_id: "Azq7EgV4oPCVI7Iw",
        unit_id: "ai_credits",
        is_unlimited: false,
        limit: "250",
        change_reason: "Customer-approved limit change"
    });

    console.log(result);
    const ledgerAccountBalance = result.ledger_account_balance;
} 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->ledgerAccountBalance()->updateOverdraftLimit([
    "subscription_id" => "Azq7EgV4oPCVI7Iw",
    "unit_id" => "ai_credits",
    "is_unlimited" => false,
    "limit" => "250",
    "change_reason" => "Customer-approved limit change"
]);
$ledgerAccountBalance = $result->ledger_account_balance;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.LedgerAccountBalance.update_overdraft_limit(
    cb_client.LedgerAccountBalance.UpdateOverdraftLimitParams(
        subscription_id="Azq7EgV4oPCVI7Iw",
        unit_id="ai_credits",
        is_unlimited=False,
        limit="250",
        change_reason="Customer-approved limit change"
    )
)
print(response)
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::LedgerAccountBalance.update_overdraft_limit({
  :subscription_id => "Azq7EgV4oPCVI7Iw",
  :unit_id => "ai_credits",
  :is_unlimited => false,
  :limit => "250",
  :change_reason => "Customer-approved limit change"
})
```

## Sample Response

```json
{
  "subscription_id": "Azq7EgV4oPCVI7Iw",
  "unit_id": "ai_credits",
  "change_reason": "Customer-approved limit change",
  "overdraft_balance": {
    "is_unlimited": false,
    "limit": "250",
    "total_balance": "210",
    "usable_balance": "200",
    "used_amount": "40",
    "hold_amount": "10"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/ledger_account_balances/update_overdraft_limit

## Input Parameters

- `subscription_id` (required, string, max chars=50)
  A unique, immutable identifier for the [subscription](/docs/api/subscriptions/subscription-object#id) whose overdraft limit is being changed.

- `unit_id` (required, string, max chars=50)
  Identifier of the [credit unit](/docs/api/credit_units) linked to the subscription. For example, a credit unit id such as `ai_credits`.
  
  **Prerequisites**
  
  An [overdraft balance](/docs/api/ledger_account_balances#overdraft_balance) must already exist for this `(subscription_id, unit_id)` pair.

- `is_unlimited` (required, boolean)
  Whether the overdraft limit for this credit unit is unlimited.
  
  **Behavior**
  
  -   When `true`, requests unlimited overdraft and [`limit`](#limit) must not be passed.
  -   When `false`, requests a finite overdraft and [`limit`](#limit) is required.

- `limit` (optional, string, max chars=36)
  The new maximum overdraft allowed for this credit unit. Pass this value as a decimal string.
  
  **Required if**
  
  [`is_unlimited`](#is_unlimited) is `false`.
  
  **Constraints**
  
  -   Must not be passed when [`is_unlimited`](#is_unlimited) is `true`.
  -   Must be zero or a positive value; negative values are not allowed.
  -   Maximum supported value: `9999999999999999999999999.9999999999` (up to 25 digits before the decimal and up to 10 digits after).
  -   Must be greater than or equal to the sum of `used_amount` and `hold_amount` on the active [overdraft balance](/docs/api/ledger_account_balances#overdraft_balance). Any limit that would drop below the already committed amount is rejected.

- `change_reason` (optional, string, max chars=255)
  The reason for this overdraft limit change, for your reference. Recorded for audit purposes.

## Returns

- `subscription_id` (required, string, max chars=50)
  A unique, immutable identifier for the [subscription](/docs/api/subscriptions/subscription-object#id) whose overdraft limit was changed. Echoes the value passed in the request.

- `unit_id` (required, string, max chars=50)
  Identifier of the [credit unit](/docs/api/credit_units) linked to the subscription. Echoes the value passed in the request.

- `change_reason` (optional, string, max chars=255)
  The reason for this overdraft limit change. Echoes the value passed in the request. This field is omitted from the response when the request does not include it.

- `overdraft_balance` (required, jsonobject)
  The resulting [`overdraft_balance`](/docs/api/ledger_account_balances#overdraft_balance) for the subscription and credit unit, reflecting the newly applied limit.
