# Cancel an invoice

`POST /lokta-lms/api/v1/invoices/{id}/cancellation`

Cancels a partner invoice, with a reason.

`reason` is required (`422 sourcing/invoice_cancel_reason_required`).

**The invoice number is kept.** GST requires a consecutive series, so a cancelled number stays spent and its invoice stays readable as cancelled; reissuing it would put two different documents under one reference, which is what consecutive numbering exists to prevent. A hole in the series and a reused number are both audit findings; keeping the row is neither, and the reason is what explains it to whoever reads the series.

**Refused while anything is settled against it** (`409 sourcing/invoice_already_paid`). A cancelled invoice with a payment attached is unresolvable: the money left, and the document saying why no longer stands. The guard reads net settlement (`sum(amount_paid)`, contras included), so reversing the payments clears it; an invoice can be cancelled once nothing is settled against it.

The accruals behind it return to `accrued`, so a later run can invoice them again. The work was done and the partner is still owed for it. Only the document was withdrawn.

## Parameters
- `id` (path, string, required)
- `Idempotency-Key` (header, string): Per-intent key

## Request body (application/json)
- `reason` (string, required): Required. It explains the cancelled number to whoever reads the series.

## Responses
- `default`: default response

## Example request (cURL)
```bash
curl -X POST \
  'https://default.lokta.tech/lokta-lms/api/v1/invoices/{id}/cancellation' \
  -u '{username}:{password}' \
  -H 'Tenant-Identifier: default' \
  -H 'Content-Type: application/json' \
  -d '{
  "reason": "string"
}'
```

Interactive: https://developer.lokta.ai/reference#operation/cancel
