## Cancel a sales order with its purchase order drafts (tenant:purchase-cart:write)

`POST /api/trade/v1/sales/order-confirmations/{id}/cancel`

Module: Trade · operationId: `cancelOrderConfirmation` · Tag: Purchasing · Auth: access token (`Authorization: Bearer <accessToken>`)

In one transaction: the order becomes `cancelled`; its draft purchase orders whose every line was bought for
this order are cancelled; its open purchase recommendations are deleted; its cart lines without purchase order
are flagged `Auftrag storniert` (they stay in the cart, the cart's proposal is dropped). Purchase orders that
are open or further, or drafts that also serve other orders, are listed back (`openPurchaseOrders`) – the
buyer decides. Earlier revisions of the order count as the order. Writes `trade.order.cancelled`.
Idempotent: cancelling a cancelled order answers it unchanged and writes nothing.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |

### Responses

- **200** The cancelled order and what happened to its purchasing (`application/json`)
- **401** No valid session or bearer token (no body).
- **403** Missing permission, no active tenant in the token, or a missing CSRF token on a cookie write. (`application/json`)
- **404** Not an order of the tenant. (`application/json`)
- **409** `order_superseded` (the order has a newer revision; cancel that one), `order_closed` (the order is in a
final status: done, delivered, shipped, revoked, expired or converted) or `order_busy` (lines of the order
were moving into carts meanwhile; try again).
 (`application/json`)
- **423** An active workflow locks the transaction. (`application/json`)

Fields of the 200 answer:

- `cancelledPurchaseOrders` (array of LinkedPurchaseOrder): Drafts that served only this order and were cancelled with it.
  - `dropShip` (boolean): The supplier delivers straight to the customer.
  - `id` (string (uuid)): Id of the purchase order.
  - `poNumber` (string): Number of the purchase order.
  - `status` (string): Status of the purchase order.
  - `supplierAddressId` (string): Masterdata address of the supplier.
  - `supplierName` (string): Name of the supplier.
- `flaggedCartLines` (integer): Cart lines of the order flagged "Auftrag storniert".
- `openPurchaseOrders` (array of LinkedPurchaseOrder): Purchase orders still active for the order (open or further, drafts that also serve other orders or are locked by a workflow); the buyer decides about them.
  - `dropShip` (boolean): The supplier delivers straight to the customer.
  - `id` (string (uuid)): Id of the purchase order.
  - `poNumber` (string): Number of the purchase order.
  - `status` (string): Status of the purchase order.
  - `supplierAddressId` (string): Masterdata address of the supplier.
  - `supplierName` (string): Name of the supplier.
- `order` (Transaction)
  - `addressId` (string (uuid)): Masterdata address of the partner.
  - `createdAt` (string (date-time), read-only): When the transaction was created.
  - `currency` (string): ISO 4217; EUR when empty.
  - `customerNo` (string, read-only): Customer number of the tenant.
  - `deliveryDate` (string (date-time)): Delivery date.
  - `documentDate` (string (date-time)): Today when empty on create.
  - `documentRefId` (string (uuid)): DMS document of the transaction.
  - `dueDate` (string (date-time)): Due date.
  - `eInvoiceValidation` (object, read-only): The newest e-invoice check of the document (details: `getInvoiceValidation`). Set only for invoices and credit notes, only on reads (`listTransactions`, `getTransaction`), and absent when no check ran.
  - `error` (string, read-only): Error of the last processing (e.g. of an inbound invoice).
  - `exchangeRate` (number): 1 when empty.
  - `externalTransactionNumber` (string): The other party's number: the supplier's invoice number (inbound invoices) or order confirmation number (purchase orders; only there it is written through this API).
  - `footerText` (string): Text printed below the lines.
  - `frozenSnapshot` (object, read-only): Evidence copy of an accepted offer; written once.
  - `grossTotal` (number, read-only): Gross total, computed from the lines.
  - `headerText` (string): Text printed above the lines.
  - `id` (string (uuid), read-only): Id of the transaction.
  - `items` (array of TransactionLine): Lines; on update they replace all lines when present.
    - `name` (string, required): Name of the article or line.
    - `quantity` (number, required): Quantity.
    - `articleNumber` (string): Article number in masterdata.
    - `createdAt` (string (date-time), read-only): When the line was created.
    - `description` (string): Description of the line.
    - `discountPercent` (number): Discount in percent.
    - `ean` (string): EAN (GTIN) of the article.
    - `id` (string (uuid), read-only): Id of the line.
    - `isOptional` (boolean): The line is optional (position type `optional`).
    - `isSelected` (boolean): Selected optional lines count in the totals.
    - `lineData` (object): Facts of the line by type (e.g. serial numbers, sources).
    - `mpn` (string): Manufacturer part number.
    - `parentItemId` (string (uuid)): Line this line belongs to (e.g. a component of a bundle).
    - `positionNumber` (integer, read-only): Set from the order of `items`.
    - `positionType` (PositionType)
    - `predecessorLineId` (string (uuid), read-only): The line of the previous version.
    - `productId` (string (uuid)): Masterdata article (product) id.
    - `sortOrder` (integer): Sort order (ascending).
    - `sourceLineId` (string (uuid), read-only): Line this one was made from (order line of a delivery note or draft invoice, invoice line of a credit note). Set by the system; a value sent by a client is dropped.
    - `taxRate` (number): Percent.
    - `totalPriceGross` (number, read-only): Gross total of the line, computed.
    - `totalPriceNet` (number, read-only): Net total of the line, computed.
    - `transactionId` (string (uuid), read-only): Id of the transaction.
    - `unit` (string): Unit of measure.
    - `unitPriceNet` (number): Negative for a credit position.
    - `updatedAt` (string (date-time), read-only): When the line was last changed.
  - `metadata` (object): `metadata.workflow` is owned by the workflow module and kept on every write.
  - `netDays` (integer): Days until the net amount is due.
  - `netTotal` (number, read-only): Computed from the lines.
  - `numberPending` (boolean, read-only): A draft invoice or credit note another module made: `transactionNumber` is its id until `releaseTransaction` gives it the gapless number. Edits keep its number and status.
  - `opportunityId` (string (uuid)): The crm opportunity the document was made for. Only the format is checked (400 `invalid`, `field` `opportunityId`). A document made from another one (`sourceTransactionId`, e.g. the order of an accepted offer) inherits it; an update without it keeps the stored one. Carried in the events `trade.transaction.*` and `trade.offer.accepted`.
  - `partnerReference` (string): The partner's order reference (BT-13).
  - `paymentMethodCode` (string): Code of the payment method in masterdata.
  - `paymentTermCode` (string): Code of the payment terms: a snapshot taken when the document is made.
  - `paymentTermsText` (string): Payment terms as printed text.
  - `predecessorId` (string (uuid)): Previous version of the same document.
  - `recipientAddress` (object): Address snapshot of the partner.
  - `recipientCompany` (string): Company of the recipient.
  - `recipientEmail` (string): E-mail of the recipient.
  - `recipientName` (string): Name of the recipient.
  - `skontoDays1` (integer): Days of the first cash discount.
  - `skontoDays2` (integer): Days of the second cash discount.
  - `skontoRate1` (number): Rate in percent of the first cash discount.
  - `skontoRate2` (number): Rate in percent of the second cash discount.
  - `sourceKind` (string): Where it came from: `MANUAL` (default), `PORTAL`, or the e-invoice/OCR kind of inbound invoices.
  - `sourceTransactionId` (string (uuid)): Document this one was made from.
  - `status` (TransactionStatus): Sales statuses are `DRAFT`, `SENT`, `ACCEPTED`, `EXPIRED`, `REVOKED`, `CONVERTED`; delivery notes made from an order are `DELIVERED` or `CANCELLED`; issued invoices and credit notes are `ISSUED` (set only by `issueInvoiceDraft`); purchase orders, goods receipts, inbound invoices and documents of the snapshot API use their own statuses (e.g. `open`, `posted`, `MATCHED`, `issued`).
  - `taxTotal` (number, read-only): Tax total, computed from the lines.
  - `tenantName` (string, read-only): Name of the tenant.
  - `transactionNumber` (string): Assigned with the type's prefix when empty on create.
  - `transactionType` (string): Code of a type of the tenant's catalogue; required on create.
  - `typeData` (object): Facts of exactly one type (e.g. `extraction` of inbound invoices, `acceptance` of accepted offers, `sources` of a draft invoice, `correctedInvoice` and `returnToStock` of a credit note, `einvoice` of an issued invoice, `dropShipDelivery` of a drop-ship delivery note, `issueRefusal` {`reason`, `problems`, `at`, `mspInvoiceId`} of a draft invoice whose issue the MSP poster refused – issuing it with `issueInvoiceDraft` marks that MSP invoice `posted`).
  - `updatedAt` (string (date-time), read-only): When the transaction was last changed.
  - `validUntil` (string (date-time)): Offers only.
  - `version` (integer, read-only): Version of the document (`createTransactionRevision` adds one).

Example 200 answer:

```json
{
  "cancelledPurchaseOrders": [
    {
      "dropShip": false,
      "id": "1b4c5d6e-7f8a-4b9c-8d0e-2f3a4b5c6d07",
      "poNumber": "BE-2026-0067",
      "status": "cancelled",
      "supplierAddressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d01",
      "supplierName": "Nordlicht IT-Distribution GmbH"
    }
  ],
  "flaggedCartLines": 1,
  "openPurchaseOrders": [],
  "order": {
    "addressId": "3c5e7a91-2b4d-4f6a-8c1e-5d7f9a0b1c05",
    "currency": "EUR",
    "documentDate": "2026-11-12T00:00:00Z",
    "grossTotal": 2673.93,
    "id": "2f6b1d84-7c3e-4a5b-9e21-6a0c4d8b1e06",
    "netTotal": 2247,
    "recipientCompany": "Donau Maschinenbau AG",
    "status": "cancelled",
    "taxTotal": 426.93,
    "transactionNumber": "AB-2026-0145",
    "transactionType": "ORDER",
    "updatedAt": "2026-11-19T15:02:00Z",
    "version": 1
  }
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/trade/v1/sales/order-confirmations/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/cancel' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
