---
title: "cancel sales order"
method: POST
path: "/api/v1/sales/orders/{order_id}/cancel"
tags: ["orders"]
---

# cancel sales order

`POST /api/v1/sales/orders/{order_id}/cancel`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/sales/orders/{order_id}/cancel`
- Auth: HTTP bearer

Cancels an order Tightly owns and releases every unit it was holding, so the stock is sellable again in the same request. A reason is optional and is kept on the document.

Allowed from `draft`, `open` and `allocated`, and from `fulfilment_requested` only while the warehouse request is still queued or has failed, or once the warehouse confirms the cancel.

An order that came from a connected channel is cancelled in the channel, not here; an order a warehouse already holds is refused until the warehouse answers.

Scope: `orders:write`, which includes `orders:read`.

## Path parameters

- `order_id` string, required

## Headers

- `Tightly-Version` string
- `Idempotency-Key` string

## Request body

- CancelSalesOrderRequest
  - `reason` string, nullable

## Response `200`

The order, cancelled.

## Other responses

- `401`: No usable key: malformed, unknown, revoked, expired or stopped.
- `403`: The key does not hold Orders (`scope_missing`), or is issued to one account and the record is not that account's (`account_mismatch`).
- `404`: No order with that id is on file.
- `409`: `channel_order_is_the_channels`, `order_locked_for_fulfilment`, `order_already_fulfilled`, `order_already_cancelled`.
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
