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

# Issue a credit note for a discount

> Reference an existing invoice when crediting MXN 100 plus IVA.

<Note>**Mexico example.** This walkthrough uses the Mexican CFDI flow. For another
issuing country, start with [shared fields and country rules](/concepts/shared-fields).</Note>

**Case:** after issuing the consulting invoice, you grant a MXN 100 discount plus MXN 16 IVA.
A credit note records the fiscal adjustment. It does not refund money through a payment processor.

Use `INVOICE_UUID` from [the invoice recipe](/recipes/invoice). This example uses a
CFDI `E` related to the original CFDI with relationship `01` (nota de crédito).
The exact treatment must match the underlying transaction.

```bash theme={null}
set -euo pipefail
jq --arg uuid "$INVOICE_UUID" 'del(.invoice_type) + {
  payment_method: "PUE",
  payment_form: "03",
  idempotency_key: "order-1042-credit-1",
  related_documents: [{relationship: "01", documents: [$uuid]}],
  items: [.items[0] + {unit_price: 100}]
}' draft-body.json > credit-note-body.json

curl --fail-with-body "$GIGSTACK_BASE_URL/invoices/egress" \
  -H "Authorization: Bearer $GIGSTACK_API_KEY" \
  -H 'Content-Type: application/json' \
  --data @credit-note-body.json > credit-note.json

jq '.data | {uuid, invoice_type, status, subtotal, taxes, total, livemode}' credit-note.json
```

**Observed in test mode:** HTTP `200`, a new UUID, `invoice_type: "E"`, `status: "valid"`,
subtotal `100`, taxes `16`, total `116`, and `livemode: false`.

Keep both UUIDs and verify the relationship on the new document. Use the recipient and
fiscal values appropriate to the credit note; do not treat these example codes as defaults.
See [invoice relationships](/guides/catalogs/invoice_relationships) and
[the full egress contract](/reference/createInvoicesEgress).

## Credit note, refund, or cancellation?

| Intent | Operation to investigate |
| - | - |
| Document a fiscal discount or return | Egress CFDI / credit note |
| Return money through the payment processor | [Refund payment](/reference/createPaymentsByIdRefund) |
| Cancel an issued CFDI | [Cancel invoice](/reference/cancelInvoice) |
| Discard an unissued draft | [Delete draft](/reference/deleteInvoicesDraftById) |

Each operation has its own result and restrictions. Completing one does not establish
that the others happened. In particular, requesting CFDI cancellation is not always
confirmation that the cancellation is final.


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