# Update Credit Note Details

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


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

Updates the [custom fields](/docs/api/advanced-features#custom-fields) and comment of a [credit note](/docs/api/credit_notes).

Use this operation to add or change custom field values, or to attach an internal comment, without modifying other credit note attributes. Pass at least one credit note custom field or `comment`; otherwise the credit note is returned unchanged.

### Impacts

**

Credit note

**

-   Updates any credit note [custom fields](/docs/api/advanced-features#custom-fields) included in the request. Existing custom field values that you omit from the request are left unchanged.
-   Adds an internal [comment](/docs/api/comments) when you pass `comment`.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/credit_notes/__demo_cn__7/update \
     -u {site_api_key}:\
     -d cf_gender="Male" \
     -d comment="Updated credit note details"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = CreditNote.Update("__demo_cn__7")
		.Comment("Updated credit note details")
		.Param("cf_gender", "Male")
		.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"
    "github.com/chargebee/chargebee-go/v3/models/creditnote"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := creditnoteAction.Update("__demo_cn__7", &creditnote.UpdateRequestParams{
        Comment : "Updated credit note details",
    }).AddParams("cf_gender", "Male").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.CreditNoteUpdateRequest{
    Comment : "Updated credit note details",
}
  req.AddCustomField("cf_gender", "Male")
  res, err := client.CreditNote.Update("__demo_cn__7", 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.update("__demo_cn__7")
            .comment("Updated credit note details")
            .param("cf_gender", "Male")
            .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.CreditNoteUpdateParams;
import com.chargebee.v4.models.creditNote.responses.CreditNoteUpdateResponse;

public class CreditNoteUpdate {

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

        CreditNoteUpdateParams params = CreditNoteUpdateParams.builder()
            .comment("Updated credit note details")
            .customField("cf_gender", "Male")
            .build();

        CreditNoteUpdateResponse response = client
            .creditNotes()
            .update("__demo_cn__7", params);

        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.update("__demo_cn__7", {
        comment: "Updated credit note details",
        cf_gender: "Male"
    });

    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()->update("__demo_cn__7", [
    "comment" => "Updated credit note details",
    "cf_gender" => "Male"
]);
$creditNote = $result->credit_note;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.CreditNote.update("__demo_cn__7",
    cb_client.CreditNote.UpdateParams(
        comment="Updated credit note details",
        cf_gender="Male"
    )
)
credit_note = response.credit_note
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::CreditNote.update("__demo_cn__7",{
  :comment => "Updated credit note details",
  "cf_gender" => "Male"
})

credit_note = result.credit_note
```

## Sample Response

```json
{
  "credit_note": {
    "allocations": {},
    "amount_allocated": 0,
    "amount_available": 500,
    "amount_refunded": 0,
    "base_currency_code": "USD",
    "cf_gender": "Male",
    "create_reason_code": "Product Unsatisfactory",
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWT0XH7a",
    "date": 1517501414,
    "deleted": false,
    "exchange_rate": 1,
    "fractional_correction": 0,
    "id": "__demo_cn__7",
    "line_item_discounts": {},
    "line_item_taxes": {},
    "line_items": [
      {
        "amount": 500,
        "customer_id": "__test__KyVnHhSBWT0XH7a",
        "date_from": 1517501414,
        "date_to": 1517501414,
        "description": "Support Charge",
        "discount_amount": 0,
        "entity_type": "adhoc",
        "id": "li___test__KyVnHhSBWT0c77n",
        "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__7",
    "resource_version": 1517501414000,
    "round_off_amount": 0,
    "status": "refund_due",
    "sub_total": 500,
    "taxes": {},
    "total": 500,
    "type": "refundable",
    "updated_at": 1517501414
  }
}
```

## URL Format

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

## Input Parameters

- `comment` (optional, string, max chars=300)
  An internal [comment](/docs/api/comments) to be added for this operation, to the credit note. This comment is displayed on the Chargebee UI. It is not displayed on any customer-facing [Hosted Page](/docs/api/hosted_pages) or any document such as the [Credit Note PDF](/docs/api/credit_notes/retrieve-credit-note-as-pdf) .

## Returns

- `credit_note` (Credit note object)
  The updated [credit note](/docs/api/credit_notes).
