Skip to content
Checkout: invoices
POST/v0/invoices/{id}/cancel

Cancel an invoice

Only while open or underpaid. An invoice with a payment in flight is never canceled, so no customer pays an invoice we have written off.

A secret key (ik_) as a Bearer token. The prefix sets the mode: _test_ or _live_. Publishable keys (pk_) cannot call it.

  • idRequired · path
  • 200The canceled invoice
curl
curl https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel \
-X POST \
-H 'authorization: Bearer $INTENTS_SECRET_KEY'
TypeScript
const response = await fetch("https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel", {
method: "POST",
headers: {
authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`,
},
});
if (!response.ok) {
const { error } = await response.json();
throw new Error(`${error.code}: ${error.message}`);
}
const data = await response.json();
Python
import os
import httpx
response = httpx.post(
"https://api.intents.fi/v0/invoices/inv_3QkR7mVt9zLpXdB2hJn6Yw/cancel",
headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},
)
response.raise_for_status()
data = response.json()
{ "error": { "code": "INVOICE_EXPIRED", "message": "This invoice has expired" } }

Switch on code, not on the message: every code has a page under Error codes. Base URL https://api.intents.fi; the whole reference is on one page.