# List invoice retry contexts

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


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

Returns invoices together with the retry segment and retry settings locked on them when their dunning started.

Pass `invoice_id[is]` to read the context of one invoice, or `retry_segment_id[is]` to list every invoice locked on a segment. A segment that has since been deleted still returns its invoices.

Each entry pairs the `invoice` with its `invoice_retry_context`, since invoices on the same segment can carry different locked settings.

### Prerequisites & Constraints

-   Retry segments are enabled for the site. Otherwise, the list is empty.

### Implementation Notes

Pass at least one of `invoice_id[is]` or `retry_segment_id[is]`. Otherwise, the API returns an `invalid_request` error.

An invoice that is not in `auto_collect` dunning has no context, so filtering by its `invoice_id` returns an empty list.

## Sample Request

### Default

#### Chargebee CLI

```bash
chargebee invoice-retry-context list \
    -d 'invoice_id[is]=__demo_inv__17'
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoice_retry_contexts \
     -G  \
     -u {site_api_key}:\
     --data-urlencode "invoice_id[is]"="__demo_inv__17"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = InvoiceRetryContext.List()
		.InvoiceId().Is("__demo_inv__17")
		.Request();

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

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    invoiceretrycontextAction "github.com/chargebee/chargebee-go/v3/actions/invoiceretrycontext"
    "github.com/chargebee/chargebee-go/v3/models/invoiceretrycontext"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceretrycontextAction.List(&invoiceretrycontext.ListRequestParams{
        InvoiceId : &filter.StringFilter{
            Is : "__demo_inv__17",
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
            InvoiceRetryContext := res.List[idx].InvoiceRetryContext
        }
    }
}
```

#### 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.InvoiceRetryContextListRequest{
    InvoiceId : &chargebee.StringFilter{
        Is : "__demo_inv__17",
    },
}
  res, err := client.InvoiceRetryContext.List(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
            InvoiceRetryContext := res.List[idx].InvoiceRetryContext
        }
    }
}
```

#### 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 = InvoiceRetryContext.list().invoiceId().is("__demo_inv__17").request();

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

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoiceRetryContext.InvoiceRetryContext;
import com.chargebee.v4.models.invoiceRetryContext.params.InvoiceRetryContextListParams;
import com.chargebee.v4.models.invoiceRetryContext.responses.InvoiceRetryContextListResponse;
import java.util.List;

public class InvoiceRetryContextList {

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

        InvoiceRetryContextListParams params = InvoiceRetryContextListParams.builder()
            .invoiceId()
            .is("__demo_inv__17")
            .build();

        InvoiceRetryContextListResponse response = client.invoiceRetryContexts().list(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoiceRetryContext.list({
        invoice_id: {
            is: "__demo_inv__17"
        }
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const invoice = entry.invoice;
        const invoiceRetryContext = entry.invoice_retry_context;
    });
} 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->invoiceRetryContext()->all([
    "invoice_id" => [
        "is" => "__demo_inv__17"
    ]
]);
foreach($result->list as $entry) {
    $invoice = $entry->invoice;
    $invoiceRetryContext = $entry->invoice_retry_context;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.InvoiceRetryContext.list(
    cb_client.InvoiceRetryContext.ListParams(
        invoice_id=Filters.StringFilter(IS="__demo_inv__17")
    )
)
for entry in entries.list:
    invoice = entry.invoice
    invoice_retry_context = entry.invoice_retry_context
```

#### Ruby

```ruby
require 'chargebee'

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

list = ChargeBee::InvoiceRetryContext.list({
  "invoice_id[is]" => "__demo_inv__17"
})

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

### List By Retry Segment

#### Chargebee CLI

```bash
chargebee invoice-retry-context list \
    -d 'retry_segment_id[is]=__test__KyVkSOVWbgWtUY' \
    -d 'invoice[dunning_status][is]=in_progress' \
    -d limit=1
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoice_retry_contexts \
     -G  \
     -u {site_api_key}:\
     --data-urlencode "retry_segment_id[is]"="__test__KyVkSOVWbgWtUY" \
     --data-urlencode "invoice[dunning_status][is]"="in_progress" \
     --data-urlencode limit=1
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = InvoiceRetryContext.List()
		.Limit(1)
		.RetrySegmentId().Is("__test__KyVkSOVWbgWtUY")
		.InvoiceDunningStatus().Is(Invoice.DunningStatusEnum.InProgress)
		.Request();

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

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    invoiceretrycontextAction "github.com/chargebee/chargebee-go/v3/actions/invoiceretrycontext"
    "github.com/chargebee/chargebee-go/v3/models/invoiceretrycontext"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceretrycontextAction.List(&invoiceretrycontext.ListRequestParams{
        Invoice : &invoiceretrycontext.ListInvoiceParams{
            DunningStatus : &filter.EnumFilter{
                Is : "in_progress",
            },
        },
        Limit : chargebee.Int32(1),
        RetrySegmentId : &filter.StringFilter{
            Is : "__test__KyVkSOVWbgWtUY",
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
            InvoiceRetryContext := res.List[idx].InvoiceRetryContext
        }
    }
}
```

#### 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.InvoiceRetryContextListRequest{
    Invoice : &chargebee.InvoiceRetryContextListInvoice{
        DunningStatus : &chargebee.EnumFilter{
            Is : "in_progress",
        },
    },
    Limit : chargebee.Int32(1),
    RetrySegmentId : &chargebee.StringFilter{
        Is : "__test__KyVkSOVWbgWtUY",
    },
}
  res, err := client.InvoiceRetryContext.List(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Invoice := res.List[idx].Invoice
            InvoiceRetryContext := res.List[idx].InvoiceRetryContext
        }
    }
}
```

#### 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 = InvoiceRetryContext.list()
            .limit(1)
            .retrySegmentId().is("__test__KyVkSOVWbgWtUY")
            .invoiceDunningStatus().is(Invoice.DunningStatus.IN_PROGRESS)
            .request();

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

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoiceRetryContext.InvoiceRetryContext;
import com.chargebee.v4.models.invoiceRetryContext.params.InvoiceRetryContextListParams;
import com.chargebee.v4.models.invoiceRetryContext.responses.InvoiceRetryContextListResponse;
import java.util.List;

public class InvoiceRetryContextList {

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

        InvoiceRetryContextListParams.InvoiceParams invoice =
            InvoiceRetryContextListParams.InvoiceParams.builder()
                .dunningStatus()
                .is(InvoiceRetryContextListParams.InvoiceParams.DunningStatus.IN_PROGRESS)
                .build();

        InvoiceRetryContextListParams params = InvoiceRetryContextListParams.builder()
            .limit(1)
            .invoice(invoice)
            .retrySegmentId()
            .is("__test__KyVkSOVWbgWtUY")
            .build();

        InvoiceRetryContextListResponse response = client.invoiceRetryContexts().list(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoiceRetryContext.list({
        retry_segment_id: {
            is: "__test__KyVkSOVWbgWtUY"
        },
        invoice: {
            dunning_status: {
                is: "in_progress"
            }
        },
        limit: 1
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const invoice = entry.invoice;
        const invoiceRetryContext = entry.invoice_retry_context;
    });
} 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->invoiceRetryContext()->all([
    "retry_segment_id" => [
        "is" => "__test__KyVkSOVWbgWtUY"
    ],
    "invoice" => [
        "dunning_status" => [
            "is" => "in_progress"
        ]
    ],
    "limit" => 1
]);
foreach($result->list as $entry) {
    $invoice = $entry->invoice;
    $invoiceRetryContext = $entry->invoice_retry_context;
}
```

#### Python

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

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.InvoiceRetryContext.list(
    cb_client.InvoiceRetryContext.ListParams(
        invoice=cb_client.InvoiceRetryContext.ListInvoiceParams(
            dunning_status=Filters.EnumFilter(IS=chargebee.Invoice.DunningStatus.IN_PROGRESS)
        ),
        limit=1,
        retry_segment_id=Filters.StringFilter(IS="__test__KyVkSOVWbgWtUY")
    )
)
for entry in entries.list:
    invoice = entry.invoice
    invoice_retry_context = entry.invoice_retry_context
```

#### Ruby

```ruby
require 'chargebee'

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

list = ChargeBee::InvoiceRetryContext.list({
  :limit => 1,
  "retry_segment_id[is]" => "__test__KyVkSOVWbgWtUY",
  "invoice[dunning_status][is]" => "in_progress"
})

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

## Sample Response

```json
{
  "list": [
    {
      "invoice": {
        "adjustment_credit_notes": [],
        "amount_adjusted": 0,
        "amount_due": 500,
        "amount_paid": 0,
        "amount_to_collect": 500,
        "applied_credits": [],
        "billing_address": {
          "first_name": "Duncan",
          "last_name": "Walpole",
          "object": "billing_address",
          "validation_status": "not_validated"
        },
        "credits_applied": 0,
        "currency_code": "USD",
        "customer_id": "__test__8asyKSOcTKve4P",
        "date": 1517490277,
        "deleted": false,
        "due_date": 1517490277,
        "dunning_attempts": [],
        "exchange_rate": 1,
        "exchange_rates": [
          {
            "currency_code": "EUR",
            "rate": 1.154
          },
          {..}
        ],
        "first_invoice": true,
        "has_advance_charges": false,
        "id": "__demo_inv__17",
        "is_gifted": false,
        "issued_credit_notes": [],
        "line_items": [
          {
            "amount": 500,
            "customer_id": "__test__8asyKSOcTKve4P",
            "date_from": 1517490277,
            "date_to": 1517490277,
            "description": "SSL Charge USD Monthly",
            "discount_amount": 0,
            "entity_id": "ssl-charge-USD",
            "entity_type": "charge_item_price",
            "id": "li___test__8asyKSOcTL0N4X",
            "is_taxed": false,
            "item_level_discount_amount": 0,
            "object": "line_item",
            "pricing_model": "flat_fee",
            "quantity": 1,
            "tax_amount": 0,
            "tax_exempt_reason": "tax_not_configured",
            "unit_amount": 500
          },
          {..}
        ],
        "linked_orders": [],
        "linked_payments": [],
        "net_term_days": 0,
        "new_sales_amount": 500,
        "object": "invoice",
        "price_type": "tax_exclusive",
        "recurring": false,
        "resource_version": 1517490277579,
        "round_off_amount": 0,
        "status": "payment_due",
        "sub_total": 500,
        "tax": 0,
        "term_finalized": true,
        "total": 500,
        "updated_at": 1517490277,
        "write_off_amount": 0,
        "dunning_status": "in_progress"
      },
      "invoice_retry_context": {
        "object": "invoice_retry_context",
        "invoice_id": "__demo_inv__17",
        "retry_segment_id": "__test__KyVkSOVWbgWtUY",
        "retry_segment_name": "High-value monthly invoices",
        "retry_settings": {
          "dunning_days": 15,
          "retry_mode": "custom",
          "retry_schedule_days": [
            1,
            {..}
          ],
          "retry_weekdays": [
            "monday",
            {..}
          ],
          "retry_time_window": "09:00-21:00 America/New_York",
          "skip_retries_for_hard_failures": true,
          "flexpay": {
            "enabled": true,
            "chargebee_days": 9,
            "flexpay_days": 6
          },
          "final_actions": {
            "subscription": "retain_as_active",
            "invoice": "mark_as_not_paid"
          },
          "applies_to": {
            "future_and_trial_subs": true,
            "onetime_invoices": true
          }
        }
      }
    },
    {..}
  ]
}
```

## URL Format

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

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

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

- `invoice_retry_context` (Invoice retry context object)
  Resource object representing invoice retry context
