> ## Documentation Index
> Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Credit notes

> Estimate, issue, void and annotate credit notes with lago v2 credit-notes.

| Command | Description |
| - | - |
| `v2 credit-notes estimate` | Compute amounts and taxes without creating anything. |
| `v2 credit-notes create` | Issue a credit note on an eligible invoice. Requires a premium license. |
| `v2 credit-notes get <lago_id>` | Retrieve a credit note. |
| `v2 credit-notes list` | List credit notes. Filters include `--external-customer-id`, `--reason`, `--credit-status`, `--refund-status`, `--issuing-date-from`, `--issuing-date-to`. |
| `v2 credit-notes update <lago_id>` | Change `refund_status` or merge `metadata`. Also `patch`. |
| `v2 credit-notes void <lago_id>` | Void an eligible credit note. Confirmation-gated. |
| `v2 credit-notes download-pdf\|download-xml <lago_id>` | Return the credit note when the file exists, or queue generation. Finalized credit notes only. |
| `v2 credit-notes resend-email <lago_id>` | Queue the credit note email. `--to`, `--cc`, `--bcc`. |
| `v2 credit-notes replace-metadata <credit_note_id>` | Replace all metadata (`POST`). |
| `v2 credit-notes merge-metadata\|patch-metadata <credit_note_id>` | Merge metadata keys (`PUT` or `PATCH`). |
| `v2 credit-notes delete-metadata <credit_note_id>` | Clear all metadata. Confirmation-gated. |
| `v2 credit-notes delete-metadata-key <credit_note_id> <key>` | Remove one key. Confirmation-gated. |

## create

| Flag | Description |
| - | - |
| `--invoice-id` | The invoice's `lago_id`. |
| `--items` | JSON array of the invoice fees to credit, each with `fee_id` and `amount_cents`. |
| `--credit-amount-cents` | Part credited to the customer balance. |
| `--refund-amount-cents` | Part refunded. |
| `--offset-amount-cents` | Part offset against the invoice. |
| `--reason`, `--description` | Why the credit note was issued. |
| `--metadata` | JSON object of up to 50 string keys. |

Run `estimate` with the same `--invoice-id` and `--items` first. Credit note metadata commands need a finalized credit note.

See [credit notes](https://getlago.com/docs/v2/guide/invoicing/credit-notes/overview.md).

```bash estimate theme={"dark"}
lago v2 credit-notes estimate --invoice-id 1a901a90-1a90-1a90-1a90-1a901a901a90 \
  --items '[{"fee_id":"1a901a90-1a90-1a90-1a90-1a901a901a91","amount_cents":2000}]'
```

```bash create theme={"dark"}
lago v2 credit-notes create --invoice-id 1a901a90-1a90-1a90-1a90-1a901a901a90 \
  --reason order_change --description "API calls billed twice" \
  --items '[{"fee_id":"1a901a90-1a90-1a90-1a90-1a901a901a91","amount_cents":2000}]' \
  --credit-amount-cents 2000 --refund-amount-cents 0
```

```bash metadata theme={"dark"}
lago v2 credit-notes merge-metadata 1a901a90-1a90-1a90-1a90-1a901a901a92 \
  --input '{"metadata":{"ticket":"SUP-4821"}}'
lago v2 credit-notes delete-metadata-key 1a901a90-1a90-1a90-1a90-1a901a901a92 ticket \
  --confirm ticket
```

```bash void theme={"dark"}
lago v2 credit-notes void 1a901a90-1a90-1a90-1a90-1a901a901a92 \
  --confirm 1a901a90-1a90-1a90-1a90-1a901a901a92
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.