cancelInvoice
Requires at least one of the permissions payments:invoice:cancel or purchase:purchase_invoice:cancel.
Cancels an invoice and reverses what it caused: payment allocations on it are reversed, shipped quantities are restored on the source order, and the order's invoice status is recalculated. Money already settled against the invoice is given back through a credit note (sales invoice) or a debit note (purchase invoice). Call invoiceCancellationPreview first; the cancellation is refused if blockers exist or if the allocations changed since you read them.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {
cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {
id
invoiceNumber
supplierCode
supplierDisplayName
supplierName
status
allocations {
id
invoiceNumber
paymentNumber
createdAt
amount
appliedFromAdvance
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {\n cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {\n id\n invoiceNumber\n supplierCode\n supplierDisplayName\n supplierName\n status\n allocations {\n id\n invoiceNumber\n paymentNumber\n createdAt\n amount\n appliedFromAdvance\n }\n }\n}",
"variables": {
"id": "id",
"reverseAllocations": true
}
}
EOF
Variables:
{
"id": "id",
"reverseAllocations": true
}
Response:
{
"data": {
"cancelInvoice": {
"id": "id",
"invoiceNumber": "string",
"supplierCode": "string",
"supplierDisplayName": "string",
"supplierName": "string",
"status": "APPROVED",
"allocations": [
{
"id": "id",
"invoiceNumber": "string",
"paymentNumber": "string",
"createdAt": "2025-01-15T00:00:00Z",
"amount": 0,
"appliedFromAdvance": true
}
]
}
}
}
Cancel an invoice and reverse its payment allocations:
- GraphQL
- cURL
mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {
cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {
id
invoiceNumber
status
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CancelInvoice($id: ID!, $reverseAllocations: Boolean!) {\n cancelInvoice(id: $id, reverseAllocations: $reverseAllocations) {\n id\n invoiceNumber\n status\n }\n}",
"variables": {
"id": "INVOICE_ID",
"reverseAllocations": true
}
}
EOF
Variables:
{
"id": "INVOICE_ID",
"reverseAllocations": true
}
Response:
{
"data": {
"cancelInvoice": {
"id": "INVOICE_ID",
"invoiceNumber": "INVOICE_NUMBER",
"status": "CANCELLED"
}
}
}
cancelInvoice(
id: ID!
reverseAllocations: Boolean! = false
): Invoice!
Arguments
cancelInvoice.id ● ID! non-null scalar
The ID of the invoice.
cancelInvoice.reverseAllocations ● Boolean! non-null scalar
Whether to also reverse the payments allocated to the invoice. Defaults to false. Use invoiceCancellationPreview to see the effect first.
Type
Invoice object
A sales invoice issued to a customer or a purchase invoice received from a supplier, with its lines, totals, status and settlement.