# List invoices

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


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

Lists all the Invoices.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=5 \
     --data-urlencode "status[in]"='["paid","payment_due"]' \
     --data-urlencode "sort_by[asc]"="date"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using ChargeBee.Models.Enums;
using ChargeBee.Filters.Enums;
using Newtonsoft.Json.Linq;

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = Invoice.List()
		.Limit(5)
		.Status().In(Invoice.StatusEnum.Paid, Invoice.StatusEnum.PaymentDue)
		.SortByDate(SortOrderEnum.Asc)
		.Request();

foreach (var listItem in result.List){
  Invoice invoice = listItem.Invoice;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
    "github.com/chargebee/chargebee-go/v3/models/invoice"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.List(&invoice.ListRequestParams{
        Limit : chargebee.Int32(5),
        Status : &filter.EnumFilter{
            In : []interface{}{"paid","payment_due"},
        },
        SortBy : &filter.SortFilter{
            Asc : "date",
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
        }
    }
}
```

#### 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.InvoiceListRequest{
    Limit : chargebee.Int32(5),
    Status : &chargebee.EnumFilter{
        In : []interface{}{"paid","payment_due"},
    },
    SortBy : &chargebee.SortFilter{
        Asc : "date",
    },
}
  res, err := client.Invoice.List(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
        }
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.filters.enums.SortOrder;
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 = Invoice.list()
            .limit(5)
            .status().in(Invoice.Status.PAID, Invoice.Status.PAYMENT_DUE)
            .sortByDate(SortOrder.ASC)
            .request();

        for (ListResult.Entry entry : result) {
            Invoice invoice = entry.invoice();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoice.params.InvoiceListParams;
import com.chargebee.v4.models.invoice.responses.InvoiceListResponse;
import java.util.List;

public class InvoiceList {

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

        InvoiceListParams params = InvoiceListParams.builder()
            .limit(5)
            .status()
            .in(InvoiceListParams.Status.PAID, InvoiceListParams.Status.PAYMENT_DUE)
            .sortBy()
            .date()
            .asc()
            .build();

        InvoiceListResponse response = client.invoices().list(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoice.list({
        limit: 5,
        status: {
            in: ["paid", "payment_due"]
        },
        "sort_by[asc]": "date"
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const invoice = entry.invoice;
    });
} 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->invoice()->all([
    "limit" => 5,
    "status" => [
        "in" => ["paid", "payment_due"]
    ],
    "sort_by" => [
        "asc" => "date"
    ]
]);
foreach($result->list as $entry) {
    $invoice = $entry->invoice;
}
```

#### Python

```python
import chargebee
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.Invoice.list(
    cb_client.Invoice.ListParams(
        limit=5,
        status=Filters.EnumFilter(IN=[chargebee.Invoice.Status.PAID, chargebee.Invoice.Status.PAYMENT_DUE]),
        sort_by=Filters.SortFilter(ASC="date")
    )
)
for entry in entries.list:
    invoice = entry.invoice
```

#### Ruby

```ruby
require 'chargebee'

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

list = ChargeBee::Invoice.list({
  :limit => 5,
  "status[in]" => "[\"paid\",\"payment_due\"]",
  "sort_by[asc]" => "date"
})

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

## Sample Response

```json
{
  "list": [
    {
      "invoice": {
        "adjustment_credit_notes": {},
        "amount_adjusted": 0,
        "amount_due": 0,
        "amount_paid": 1000,
        "amount_to_collect": 0,
        "applied_credits": {},
        "base_currency_code": "USD",
        "billing_address": {
          "first_name": "John",
          "last_name": "Mathew",
          "object": "billing_address",
          "validation_status": "not_validated"
        },
        "credits_applied": 0,
        "currency_code": "USD",
        "customer_id": "__test__8asyKSOcTHxf1V",
        "date": 1517490266,
        "deleted": false,
        "due_date": 1517490266,
        "dunning_attempts": {},
        "exchange_rate": 1,
        "first_invoice": true,
        "has_advance_charges": false,
        "id": "__demo_inv__7",
        "is_gifted": false,
        "issued_credit_notes": [
          {
            "cn_create_reason_code": "Subscription Change",
            "cn_date": 1517490267,
            "cn_id": "__demo_cn__2",
            "cn_reason_code": "subscription_change",
            "cn_status": "refunded",
            "cn_total": 1000
          },
          {..}
        ],
        "line_items": [
          {
            "amount": 1000,
            "customer_id": "__test__8asyKSOcTHxf1V",
            "date_from": 1517490266,
            "date_to": 1519909466,
            "description": "basic USD",
            "discount_amount": 0,
            "entity_id": "basic-USD",
            "entity_type": "plan_item_price",
            "id": "li___test__8asyKSOcTI6v1e",
            "is_taxed": false,
            "item_level_discount_amount": 0,
            "object": "line_item",
            "pricing_model": "per_unit",
            "quantity": 1,
            "subscription_id": "__test__8asyKSOcTI3k1c",
            "tax_amount": 0,
            "tax_exempt_reason": "tax_not_configured",
            "unit_amount": 1000
          },
          {..}
        ],
        "linked_orders": {},
        "linked_payments": [
          {
            "applied_amount": 1000,
            "applied_at": 1517490266,
            "txn_amount": 1000,
            "txn_date": 1517490266,
            "txn_id": "txn___test__8asyKSOcTIAy1f",
            "txn_status": "success"
          },
          {..}
        ],
        "net_term_days": 0,
        "new_sales_amount": 1000,
        "object": "invoice",
        "paid_at": 1517490266,
        "price_type": "tax_exclusive",
        "recurring": true,
        "resource_version": 1517490268022,
        "round_off_amount": 0,
        "status": "paid",
        "sub_total": 1000,
        "subscription_id": "__test__8asyKSOcTI3k1c",
        "tax": 0,
        "term_finalized": true,
        "total": 1000,
        "updated_at": 1517490268,
        "write_off_amount": 0
      }
    },
    {..}
  ],
  "next_offset": "[\"1517490271000\",\"243000000410\"]"
}
```

## URL Format

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

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  The number of resources to be returned.

- `offset` (optional, string, max chars=1000)
  Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set `offset` to the value of `next_offset` obtained in the previous iteration of the API call.

- `include_deleted` (optional, boolean, default=false)
  If set to true, includes the deleted resources in the response. For the deleted resources in the response, the '**deleted** ' attribute will be '**true** '.

## 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`.

- `invoice` (Invoice object)
  Resource object representing invoice
