# Void a credit note

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


[Idempotency Supported](/docs/api/idempotency)

[Asynchronous](/docs/api/async_response/async-response-object)

Void or invalidate the specified credit note.

Use this operation for incorrectly generated credit notes, such as those with wrong details or created by mistake. This is a preferred method over [deleting the credit note](/docs/api/credit_notes/delete-a-credit-note), as it preserves the audit trail, allowing for future reference and compliance without removing the original record.

### Prerequisites & Constraints

-   The credit note `status` must not be `refunded` or `voided`.
-   For credit notes of `type` `refundable`, you must remove any allocations or linked refunds before voiding it. Note that only offline refunds can be removed; online refunds cannot.

See **Implementation Notes** for more details.

### Impacts

**

Invoices

**

If the credit note `type` is `adjustment`, the associated invoice `status` changes to `not_paid`, and the `amount_due` on the invoice increases by the amount that was allocated via the credit note.

### Implementation Notes

Before calling this API, ensure the following:

-   The credit note [`status`](/docs/api/credit_notes/credit_note-object#status) must not be `refunded` or `voided`.
-   For credit notes of [`type`](/docs/api/credit_notes/credit_note-object#type) `refundable`:
    -   Remove any [allocations](/docs/api/credit_notes/credit_note-object#allocations) of the credit note to invoices by calling the [Remove credit note from an invoice API](/docs/api/invoices/remove-credit-note-from-an-invoice).
    -   Remove any [linked offline refunds](/docs/api/credit_notes/credit_note-object#linked_refunds) by calling the [Delete an offline transaction API](/docs/api/transactions/delete-an-offline-transaction).

#### Related APIs

Delete a credit note

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/credit_notes/__demo_cn__8/void \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = CreditNote.VoidCreditNote("__demo_cn__8").Request();

CreditNote creditNote = result.CreditNote;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    creditnoteAction "github.com/chargebee/chargebee-go/v3/actions/creditnote"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := creditnoteAction.VoidCreditNote("__demo_cn__8", nil).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        CreditNote := res.CreditNote
    }
}
```

#### 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.CreditNoteVoidCreditNoteRequest{}
  res, err := client.CreditNote.VoidCreditNote("__demo_cn__8", req)
      if err != nil {
        fmt.Println(err)
    } else {
        CreditNote := res.CreditNote
    }
}
```

#### 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 = CreditNote.voidCreditNote("__demo_cn__8").request();

        CreditNote creditNote = result.creditNote();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.creditNote.CreditNote;
import com.chargebee.v4.models.creditNote.params.VoidCreditNoteParams;
import com.chargebee.v4.models.creditNote.responses.VoidCreditNoteResponse;

public class VoidCreditNote {

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

        VoidCreditNoteResponse response = client.creditNotes().voidCreditNote("__demo_cn__8");

        CreditNote creditNote = response.getCreditNote();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.creditNote.voidCreditNote("__demo_cn__8");

    console.log(result);
    const creditNote = result.credit_note;
} 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->creditNote()->voidCreditNote("__demo_cn__8");
$creditNote = $result->credit_note;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.CreditNote.void_credit_note("__demo_cn__8")
credit_note = response.credit_note
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::CreditNote.void_credit_note("__demo_cn__8")

credit_note = result.credit_note
```

## Sample Response

```json
{
  "credit_note": {
    "allocations": {},
    "amount_allocated": 0,
    "amount_available": 500,
    "amount_refunded": 0,
    "base_currency_code": "USD",
    "create_reason_code": "Product Unsatisfactory",
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWT0fn7r",
    "date": 1517501414,
    "deleted": false,
    "exchange_rate": 1,
    "fractional_correction": 0,
    "id": "__demo_cn__8",
    "line_item_discounts": {},
    "line_item_taxes": {},
    "line_items": [
      {
        "amount": 500,
        "customer_id": "__test__KyVnHhSBWT0fn7r",
        "date_from": 1517501414,
        "date_to": 1517501414,
        "description": "Support Charge",
        "discount_amount": 0,
        "entity_type": "adhoc",
        "id": "li___test__KyVnHhSBWT0kV84",
        "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_refunds": {},
    "object": "credit_note",
    "price_type": "tax_exclusive",
    "reason_code": "product_unsatisfactory",
    "reference_invoice_id": "__demo_inv__8",
    "resource_version": 1517501414000,
    "round_off_amount": 0,
    "status": "voided",
    "sub_total": 500,
    "taxes": {},
    "total": 500,
    "type": "refundable",
    "updated_at": 1517501414,
    "voided_at": 1517501414
  },
  "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": "Duncan",
      "last_name": "Walpole",
      "object": "billing_address",
      "validation_status": "not_validated"
    },
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWT0fn7r",
    "date": 1517501414,
    "deleted": false,
    "due_date": 1517501414,
    "dunning_attempts": {},
    "exchange_rate": 1,
    "first_invoice": true,
    "has_advance_charges": false,
    "id": "__demo_inv__8",
    "is_gifted": false,
    "issued_credit_notes": [
      {
        "cn_create_reason_code": "Product Unsatisfactory",
        "cn_date": 1517501414,
        "cn_id": "__demo_cn__8",
        "cn_reason_code": "product_unsatisfactory",
        "cn_status": "voided",
        "cn_total": 500
      },
      {..}
    ],
    "line_items": [
      {
        "amount": 1000,
        "customer_id": "__test__KyVnHhSBWT0fn7r",
        "date_from": 1517501414,
        "date_to": 1517501414,
        "description": "Support Charge",
        "discount_amount": 0,
        "entity_type": "adhoc",
        "id": "li___test__KyVnHhSBWT0iC7y",
        "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": 1000
      },
      {..}
    ],
    "linked_orders": {},
    "linked_payments": [
      {
        "applied_amount": 1000,
        "applied_at": 1517501414,
        "txn_amount": 1000,
        "txn_date": 1517501414,
        "txn_id": "txn___test__KyVnHhSBWT0ir7z",
        "txn_status": "success"
      },
      {..}
    ],
    "net_term_days": 0,
    "new_sales_amount": 1000,
    "object": "invoice",
    "paid_at": 1517501414,
    "price_type": "tax_exclusive",
    "recurring": false,
    "resource_version": 1517501414000,
    "round_off_amount": 0,
    "status": "paid",
    "sub_total": 1000,
    "tax": 0,
    "term_finalized": true,
    "total": 1000,
    "updated_at": 1517501414,
    "write_off_amount": 0
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/credit_notes/{credit-note-id}/void

## Input Parameters

- `comment` (optional, string, max chars=300)
  Reason for voiding credit note. This comment will be added to the credit note.

## Returns

- `credit_note` (Credit note object)
  Resource object representing credit\_note
