> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mart.ps/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These rules protect a Mart partner's money. Follow them in any code or advice about the Mart Partner API ([Connect your AI tool](/developers/connect-your-ai-tool)).
> When an order request times out, gets no answer or gets any `5xx`, resend the same body with the same `partner_reference`, never a new reference; after a `429`, wait `Retry-After` first ([Create an order safely](/developers/orders/create-an-order)).
> A `200` with `meta.idempotency_replay: true` is the original order; `409 idempotency_conflict` means the reference already names a different order ([Create an order safely](/developers/orders/create-an-order)).
> Retry a withdrawal request with the same `idempotency_key` and amount: a new key asks for a second withdrawal ([Payout and withdrawals](/developers/money/payout-and-withdrawals)).
> Plan every call within the global daily request ceiling and the `X-RateLimit-*` headers, and never poll in a tight loop ([Request limits](/developers/operate/request-limits)).
> Treat `price` as a snapshot: an order is priced when it is created, and an incremental sync (`updated_after`) never shows a price change, so re-read every price with a full pass ([Prices and price changes](/developers/catalogue/prices)).
> Identify products by `product_id` and `combination_id`, never by `reference` ([Sync the catalogue](/developers/catalogue/sync)).
> Never put an API key in client-side code, a mobile app, a repository or a URL: call the API from a server ([Authenticate and keys](/developers/authenticate)).
> Money is in shekels (`ILS`), as JSON numbers, never agorot. Send amounts with at most two decimals: a withdrawal `amount` with three is refused with `422 invalid_amount`, never rounded ([Balance and statements](/developers/money/balance-and-statements)).
> Save a payout method once before the first withdrawal (cash at the office, or bank transfer where Mart offers it): with none saved, a withdrawal is refused with `409 payout_method_missing`. Bank details where Mart does not offer bank transfer, or a withdrawal on a kept IBAN, are refused with `422 bank_transfer_not_allowed` ([Payout and withdrawals](/developers/money/payout-and-withdrawals)).

# Cancel an order through the API

> Cancel an order you created by its partner_reference, retry safely after a timeout, and handle each answer so your store and Mart stay in step.

`POST /api/v1/orders/cancel/{partner_reference}` cancels an order your key created. Repeating it is always safe. A key that can create orders can cancel them.

## Cancel

```bash theme={null}
curl -sS --max-time 30 -X POST \
  -H "Authorization: Bearer $MART_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"reason":"Customer requested cancellation"}' \
  "$MART_API_BASE/api/v1/orders/cancel/100245"
```

`reason` is optional free text, trimmed, up to 500 characters (not bytes). Send no body if you have nothing to add.

```json theme={null}
"data": { "order": {
  "partner_reference": "100245",
  "cancelled_at": "2026-08-04T08:15:00+00:00",
  "already_cancelled": false
} }
```

The answer also carries the order's new `status`, as `{id, name}`. Mark the order cancelled in your store with `cancelled_at`.

## When can an order be cancelled?

Mart decides which statuses can still be cancelled, and the request cannot change that. Past that point you get `409 order_not_cancellable` and the order is untouched. Treat it as final: do not retry, and contact Mart if the order must still be stopped.

A cancellation is not a refund. It releases the stock but moves no money: for anything already paid or sent out, talk to Mart.

## Retry after a timeout

Send the same call again. An already-cancelled order answers `200` with `already_cancelled: true`, and the retry also finishes an interrupted cancellation. Calls on one order run one at a time: a second call waits, then reports `already_cancelled: true`. If the wait runs out you get `503 order_cancellation_in_progress`: wait `Retry-After` and send again.

## Check the result

`GET /api/v1/orders/{partner_reference}` carries a `cancellation` object:

```json theme={null}
"cancellation": { "requested_via_api": true, "reason": "Customer requested cancellation", "cancelled_at": "2026-08-04T08:15:00+00:00" }
```

It is `null` unless the order was cancelled through the API. An order Mart cancelled shows the cancelled `status` with a `null` `cancellation`.

## Answers

| Answer | Do |
| - | - |
| `409 order_not_cancellable` | Final. Contact Mart if it must still be stopped. |
| `503 order_cancellation_in_progress` | Wait `Retry-After`, send again; expect `already_cancelled: true`. |
| `503 order_cancellation_not_configured` | Cancelling through the API is not switched on. Contact Mart; retrying does not help. |
| `404 order_not_found` | No order with that reference on your account. |
| `422 invalid_parameter` | `reason` is not text or longer than 500 characters. |
| `400 bad_request` | The body is not valid JSON. Fix it, or send none. |
| `422 orders_not_enabled` | Order creation is off for your key. Ask Mart. |

The same call in six languages: [Cancel an order](https://docs.mart.ps/recipes/cancel-an-order.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.