# List ledger account balances

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


[Eventually Consistent](/docs/api/read-consistency)

Returns a paginated list of real-time credit balance snapshots for a subscription. Each item in the list is a [ledger\_account\_balance](/docs/api/ledger_account_balances) object, identified by a unique combination of `subscription_id, unit_id, unit_type`.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/ledger_account_balances \
     -G  \
     -u {site_api_key}:\
     --data-urlencode "subscription_id[is]"="rT8KpLw2ZxHq9VdM1aYu" \
     --data-urlencode "unit_id[is]"="ai_credits" \
     --data-urlencode limit=10
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = LedgerAccountBalance.ListLedgerAccountBalances()
		.Limit(10)
		.SubscriptionId().Is("rT8KpLw2ZxHq9VdM1aYu")
		.UnitId().Is("ai_credits")
		.Request();

foreach (var listItem in result.List){
  LedgerAccountBalance ledgerAccountBalance = listItem.LedgerAccountBalance;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    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.ListLedgerAccountBalances(&ledgeraccountbalance.ListLedgerAccountBalancesRequestParams{
        Limit : chargebee.Int32(10),
        SubscriptionId : &filter.StringFilter{
            Is : "rT8KpLw2ZxHq9VdM1aYu",
        },
        UnitId : &filter.StringFilter{
            Is : "ai_credits",
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            LedgerAccountBalance := res.List[idx].LedgerAccountBalance
        }
    }
}
```

#### 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.LedgerAccountBalanceListLedgerAccountBalancesRequest{
    Limit : chargebee.Int32(10),
    SubscriptionId : &chargebee.StringFilter{
        Is : "rT8KpLw2ZxHq9VdM1aYu",
    },
    UnitId : &chargebee.StringFilter{
        Is : "ai_credits",
    },
}
  res, err := client.LedgerAccountBalance.ListLedgerAccountBalances(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            LedgerAccountBalance := res.List[idx].LedgerAccountBalance
        }
    }
}
```

#### 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}");
        ListResult result = LedgerAccountBalance.listLedgerAccountBalances()
            .limit(10)
            .subscriptionId().is("rT8KpLw2ZxHq9VdM1aYu")
            .unitId().is("ai_credits")
            .request();

        for (ListResult.Entry entry : result) {
            LedgerAccountBalance ledgerAccountBalance = entry.ledgerAccountBalance();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance;
import com.chargebee.v4.models.ledgerAccountBalance.params.ListLedgerAccountBalancesParams;
import com.chargebee.v4.models.ledgerAccountBalance.responses.ListLedgerAccountBalancesResponse;
import java.util.List;

public class ListLedgerAccountBalances {

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

        ListLedgerAccountBalancesParams params = ListLedgerAccountBalancesParams.builder()
            .limit(10)
            .subscriptionId()
            .is("rT8KpLw2ZxHq9VdM1aYu")
            .unitId()
            .is("ai_credits")
            .build();

        ListLedgerAccountBalancesResponse response = client.ledgerAccountBalances().listLedgerAccountBalances(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.ledgerAccountBalance.listLedgerAccountBalances({
        subscription_id: {
            is: "rT8KpLw2ZxHq9VdM1aYu"
        },
        unit_id: {
            is: "ai_credits"
        },
        limit: 10
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const ledgerAccountBalance = entry.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()->listLedgerAccountBalances([
    "subscription_id" => [
        "is" => "rT8KpLw2ZxHq9VdM1aYu"
    ],
    "unit_id" => [
        "is" => "ai_credits"
    ],
    "limit" => 10
]);
foreach($result->list as $entry) {
    $ledgerAccountBalance = $entry->ledger_account_balance;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.LedgerAccountBalance.list_ledger_account_balances(
    cb_client.LedgerAccountBalance.ListLedgerAccountBalancesParams(
        limit=10,
        subscription_id=Filters.StringFilter(IS="rT8KpLw2ZxHq9VdM1aYu"),
        unit_id=Filters.StringFilter(IS="ai_credits")
    )
)
for entry in entries.list:
    ledger_account_balance = entry.ledger_account_balance
```

#### Ruby

```ruby
require 'chargebee'

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

list = ChargeBee::LedgerAccountBalance.list_ledger_account_balances({
  :limit => 10,
  "subscription_id[is]" => "rT8KpLw2ZxHq9VdM1aYu",
  "unit_id[is]" => "ai_credits"
})

list.each do |entry|
  ledger_account_balance = entry.ledger_account_balance
end
```

## Sample Response

```json
{
  "list": [
    {
      "ledger_account_balance": {
        "subscription_id": "1mGETgZVF2umUZq",
        "unit_id": "ai_credits",
        "unit_type": "credit_unit",
        "created_at": 1746723600,
        "modified_at": 1774978599,
        "resource_version": 1774978599000,
        "provisioned_balance": {
          "total_balance": "100.25",
          "usable_balance": "49.7975",
          "hold_amount": "50.4525"
        },
        "overdraft_balance": {
          "is_unlimited": false,
          "limit": "20",
          "total_balance": "20",
          "usable_balance": "20",
          "used_amount": "0",
          "hold_amount": "0"
        },
        "object": "ledger_account_balance"
      }
    },
    {..}
  ],
  "next_offset": "[\"1774978599000\",\"9876543210000000001\"]"
}
```

## URL Format

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

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  Specifies the maximum number of resources to return per page.
  
  **Default and Hard Cap**
  
  -   Optional parameter; if omitted, a server-defined default is applied.
  -   Values exceeding the server's maximum limit are capped (clamped) to the allowed maximum.
  
  **Example →** _limit = "50"_

- `offset` (optional, string, max chars=1000)
  Opaque cursor indicating the current position in the result set for pagination.
  
  **Behavior**
  
  -   To fetch the next page, pass the `next_offset` value returned in the previous response.
  -   The value is opaque and must not be parsed, modified, or constructed manually.
  
  **Example →** _offset = "\["1771176208000","96000000006"\]"_

## Returns

- `next_offset` (optional, string, max chars=1000)
  This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter `offset`.

- `ledger_account_balance` (Ledger account balance object)
  Resource object representing a credit balance snapshot. The response is the standard Chargebee [list envelope](/docs/api/list-ops): `{ "list": [{ "ledger_account_balance": { ... } }, ...], "next_offset": "..." }`, where each `list` item wraps a single `ledger_account_balance` under its resource name.
