# Invoice Retry Context

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


An invoice retry context is the [retry segment](/docs/api/retry_segments) and the retry settings locked on an invoice when its dunning started. Chargebee retries the invoice under these settings for the rest of its dunning, even if the segment is edited or deleted later. Two invoices on the same segment can therefore carry different settings.

An invoice that matches no other segment locks the [default segment](/docs/api/retry_segments#the-default-segment), so it has a context too, named `Default segment`.

Use [List invoice retry contexts](/docs/api/invoice_retry_contexts/list-invoice-retry-contexts) to read the context of one invoice, or every invoice locked on a segment. The context is also sent in the `retry_segment_assigned` [event](/docs/api/events#event_types).

**Note:** Invoice retry contexts apply only to invoices in `auto_collect` dunning, and only when retry segments are enabled for the site.

## Sample Invoice retry context

```json
{
  "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
    }
  }
}
```

## Invoice Retry Context attributes

## Input Parameters

- `invoice_id` (required, string, max chars=50)
  Identifier of the [invoice](/docs/api/invoices) the context belongs to.

- `retry_segment_id` (required, string, max chars=40)
  Identifier of the [retry segment](/docs/api/retry_segments) the invoice matched when its dunning started.

- `retry_segment_name` (optional, string, max chars=1000)
  Name of the retry segment when the invoice matched it.

- `retry_settings` (optional, jsonobject)
  Retry settings locked on the invoice when its dunning started. Same structure as [`retry_segment.retry_settings`](/docs/api/retry_segments#retry_segment_retry_settings). The invoice is retried under these settings even if the segment is edited or deleted later.

