> For the complete documentation index, see [llms.txt](https://docs.bitsby.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bitsby.app/api-documentation/invoice-cancellation.md).

# Invoice cancellation

## Description

An invoice can be canceled to prevent the buyer from paying the invoice. This is necessary if an error has been made on the invoice. An invoice can only be canceled if two conditions are met:

* Invoice status: not paid
* Payment page views: 0 views

## Request

```bash
curl -X POST https://api.bitsby.app/invoices/cancel \
  -H "Authorization: Token MSvL2ltaDZdWVjmZURURMVWhqSJLT2NURjhL2Fla1Z1T1IxQTltKs1T3Ay" \
	-F "invoiceId=ade9550d-3dc7-4fd3-b94e-3b4c12aaaa0c"
```

## Request parameters

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Data type</th><th>Description</th><th>Example</th><th>Mandatory?</th></tr></thead><tbody><tr><td><code>invoiceId</code></td><td>UUID</td><td>Invoice ID in UUID format</td><td>ade9550d-3dc7-4fd3-b94e-3b4c12aaaa0c</td><td>yes</td></tr></tbody></table>

## Example answer

```json
{
   "result":"success",
   "data":"Invoice canceled"
}
```
