# 4. Order Cancellation 

An order can be canceled for several reasons and the initiative to cancel an order can come from the merchant, the customer, or Keeta.
It may also happen that the delivery person requests the cancellation in some  scenarios, such as when the customer is not found at the delivery address.

> **Cancellation Rules**
It is expected that both Keeta and merchant Software Service have their own order cancellation policies and inform their users.


A cancellation request must always contain:

- **reason**: Open text field indicating the reason for the cancellation.
- **code**: An enumerator containing a cancellation reason.
- **mode**: Field indicating whether the cancellation occurred Automatically or Manually.


The cancellation can be requested by:

**Software Service** (Merchant):

If the merchant wants to cancel an order, it must make a [POST /orders/{orderId}/requestCancellation](/en/apis/opendelivery/orderapi/requestcancellation) request.

> **Penalties**
Avoid order cancellations! Excessive cancellations can result in some penalties (depending on Keeta's policy) such as having the merchant temporarily closed on the platform.


**Cancellation Validation**

The Cancellation request does not guarantee that the order is cancelled. When sending a request [/orders/{orderId}/requestCancellation](/en/apis/opendelivery/orderapi/requestcancellation),  Keeta will send the code 202 (accepted) in response.
This does not yet mean
that the request has been cancelled. It means that the request has been accepted and will be processed by Keeta cancellation service. As a result of this request, the merchant Software Service may receive at the next  polling (or via webhook) one of the following events:

- CANCELLED


The order should only be Canceled when the CANCELLED event is generated.

> Cancellation rules may vary depending on the timing of the order (before or after confirmation). In some situations it is possible that  Keeta cancellation service will consult with the consumer on whether or not the  consumer accepts the cancellation of the order.


```
Cancellation codes:

- INSUFFICIENT_DISHES
- SUSPENSION_OF_BUSINESS
- INSUFFICIENT_MANPOWER
- OTHERS
```

Cancellation by **Keeta** can happen by:

```
code: CONSUMER_CANCELLATION_REQUESTED
```

The consumer can request the cancellation of an order.
Depending on the cancellation rules applied, this option may not be enabled for all merchants.
It may also only be allowed at certain times, such as before the  order is confirmed.

```
code: OTHER_CANCELLATION_REASON
```

Keetas may cancel the order for reasons other than via customer.
Possible reasons for order cancellation by the system include: timing out without acceptance,
no rider accepting the order, or the rider reporting the  store as closed.

When the Order Application initiates a cancellation, an order cancellation event is transmitted to
the Software Service via webhook or polling. The Software Service must then update the order status based on
the event  details.